473,624 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Shared properties in ASP.NET

Hi,
I'm using a custom class in my ASP.NET which has a Shared property.
I don't want this Shared property to be shared between users because of
thread concurrent accesses problems.
I just want it to be shared between the several instances of the class
belonging to the same request/user.
I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die after
each user's request has ended)
So I think I don't have to use SyncLock inside this Shared property as each
client request is run completely separately and a thread from a request
won't access the same shared property as another request's thread.
Am I right?
Thanks for your answer.

Nov 19 '05 #1
1 1751
> I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die
after
each user's request has ended)
Afraid not. Shared (static) objects are stored in the heap, and are
singletons (there is only one, no instance). The use of the syntax "shared"
is, IMHO, unfortunate, in that it is a little misleading. But what is
important is what it means. Instantiated objects are (copies of execution
code) placed on the stack, a volatile region of memory where instances are
placed while being used, and removed afterwards. Shared (static) objects
remain in the heap, a region of code into which the program execution code
is loaded (from the DLL) at startup.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Henri" <hm********@hot mail.com> wrote in message
news:ed******** *****@TK2MSFTNG P12.phx.gbl... Hi,
I'm using a custom class in my ASP.NET which has a Shared property.
I don't want this Shared property to be shared between users because of
thread concurrent accesses problems.
I just want it to be shared between the several instances of the class
belonging to the same request/user.
I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die
after
each user's request has ended)
So I think I don't have to use SyncLock inside this Shared property as
each
client request is run completely separately and a thread from a request
won't access the same shared property as another request's thread.
Am I right?
Thanks for your answer.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3552
by: John Brock | last post by:
I have a base class with several derived classes (I'm writing in VB.NET). I want each derived class to have a unique class ID (a String), and I want the derived classes to inherit from the base class *Shared* methods which make use of the class ID. So I gave the base class a classID field, and then I gave the derived classes Shared constructors, which I used to set the classID field to the appropriate values for each derived class. But...
0
2740
by: Shiraz | last post by:
Hi I have a question regarding the functionality of merge modules. Since this relates to my previous queries, I'll just give you a brief background on the topic. I had to make an installer for an application which was to share dlls with another application and these dlls were not self-registering. Someone on the forum suggested a few methods for the Visual studio installer, but since I had been using another software, a certain...
2
1625
by: Don | last post by:
I'm asking this for a friend of mine, so forgive me if I'm getting some of the terminology wrong (I don't have any experience with ASP.NET). I've got an ASP application that has some classes that have shared members. How do I set it up so that each individual session uses a different "copy" of each shared class? Right now, every session seems to share the same shared variables (like a connection to a database, for example) inside the...
3
1357
by: Chris Dunaway | last post by:
How can a class be shared between a web service and a client that consumes the web service? Suppose I have a Class Libraray with the following simple class: Public Class SimpleClass Private _AnInteger As Integer Public Property AnInteger As Integer Get
5
1575
by: Simon | last post by:
Hi all, We have an ASP.NET 1.1 application running on IIS6 on Server 2003. Most of the base objects we are using in this application are taken from a windows application also written by us. We have used shared properties on some of these objects to enable caching of frequently used objects, so save fetching them from SQL every time. These shared properties vastly increase performance of our windows app.
2
1460
by: mgoold2002 | last post by:
Hello. I've just begun programming in VB .NET, and I'm trying to turn all my modules into classes. In order to retrieve/exchange values from one class to another, I initiated New instances of the classes in each class where I needed to retrieve a property or method. I discovered that this reciprocal loading of class instances led to stackoverflow exceptions. I am now remedying this problem by sharing properties among the classes. I...
8
2015
by: Al | last post by:
I'd like to create Class Library in VB 2005, which has a property accessible by external programs. I decided to include 1 Class with 1 property in this project. I placed this code in Class: Public Class COM Private mMyProp As String Public Property MyProp() As String
1
3688
by: Tony Johansson | last post by:
Hello! If I select a private assembly in ILDASM I get a lot of information listed but if I select a shared assembly located at c:\window\assembly(GAC) I get nothing listed. So is this normal not seeing anything when using ILDASM on any shared assembly located in the GAC. Now to my second question: If I create a shared assembly from a private assembly and then use
6
1496
by: wingphil | last post by:
Hi there, I have a shared method in a base class, and I need to know which subclass it has been called from. So for example Public Mustinherit Class BaseClass Public Shared Sub SharedMethod ... End Sub
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.