473,803 Members | 2,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of shared class members in ASP.NET

I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object in
that shared member function the system maintains a local copy of that object
per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If I
have a shared member which declares a variable a of type Integer. the actual
storage of this integer I assume would be on the users one thread and cannot
be confused with anyone slses (UNLESS) the variable is static as pointed out
by Jay.

The reason this is making me paranoid is that I want to make extensive used
of shared functions in my data layer to reduce code bloat and constant
instantiation.

Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the dataset
would be overwritten, I cant see how this can be right. I decided to re-do
this posting thread to start afresh, I hope no one minds.

Sorry for being a little paranoid here, but i dont want to embark upon loads
of work and then find out Im screwed!

--
Best Regards

The Inimitable Mr Newbie º¿º
Dec 4 '05 #1
11 1276

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object
in that shared member function the system maintains a local copy of that
object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If I
have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one thread
and cannot be confused with anyone slses (UNLESS) the variable is static
as pointed out by Jay.


Local variables are allocated on the stack, which is memory that belongs
exclusively to the current thread.
David
Dec 4 '05 #2
That answers my question precisley.

Thank you

--
Best Regards

The Inimitable Mr Newbie º¿º
"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> wrote in
message news:ei******** ********@TK2MSF TNGP12.phx.gbl. ..

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object
in that shared member function the system maintains a local copy of that
object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If I
have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one thread
and cannot be confused with anyone slses (UNLESS) the variable is static
as pointed out by Jay.


Local variables are allocated on the stack, which is memory that belongs
exclusively to the current thread.
David

Dec 4 '05 #3
I'm a little confused by your use of the word "shared," and in the same
message, "static." In VB.Net, "shared" means "static." So, are you referring
to "shared" as in "static," or for some other meaning? If not "static," what
definition of "shared" are you meaning?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object
in that shared member function the system maintains a local copy of that
object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If I
have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one thread
and cannot be confused with anyone slses (UNLESS) the variable is static
as pointed out by Jay.

The reason this is making me paranoid is that I want to make extensive
used of shared functions in my data layer to reduce code bloat and
constant instantiation.

Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the dataset
would be overwritten, I cant see how this can be right. I decided to re-do
this posting thread to start afresh, I hope no one minds.

Sorry for being a little paranoid here, but i dont want to embark upon
loads of work and then find out Im screwed!

--
Best Regards

The Inimitable Mr Newbie º¿º

Dec 4 '05 #4
Mr, Newbie,
Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the dataset
would be overwritten, I cant see how this can be right.


If you had asked that original thread than I would have explained in another
way for you. As far as I know was you not the OP, if you was the OP, than
please don't confuse us.

Especially do I not understand why you send messages to the framework.aspne t
group, where in you suggest that I give wrong answers in the language.vb
newsgroup, without telling in one word what the question was.

If you are sure that my answer is wrong, than you can start a discussion or
ignore it, however telling it in other newsgroups is for me undecent.

Cor

Dec 4 '05 #5
Sorry, yes I meant the same thing, its an occupational hazard of switching
languages.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:e3******** *******@TK2MSFT NGP11.phx.gbl.. .
I'm a little confused by your use of the word "shared," and in the same
message, "static." In VB.Net, "shared" means "static." So, are you
referring to "shared" as in "static," or for some other meaning? If not
"static," what definition of "shared" are you meaning?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object
in that shared member function the system maintains a local copy of that
object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If I
have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one thread
and cannot be confused with anyone slses (UNLESS) the variable is static
as pointed out by Jay.

The reason this is making me paranoid is that I want to make extensive
used of shared functions in my data layer to reduce code bloat and
constant instantiation.

Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the
dataset would be overwritten, I cant see how this can be right. I decided
to re-do this posting thread to start afresh, I hope no one minds.

Sorry for being a little paranoid here, but i dont want to embark upon
loads of work and then find out Im screwed!

--
Best Regards

The Inimitable Mr Newbie º¿º


Dec 4 '05 #6
Im very sorry. I did not mean to upset you in any way.

I simply became confused with the answers, I should have replied on the
original thread. My appologies.
-
Best Regards

The Inimitable Mr Newbie º¿º
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
Mr, Newbie,
Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the
dataset would be overwritten, I cant see how this can be right.


If you had asked that original thread than I would have explained in
another way for you. As far as I know was you not the OP, if you was the
OP, than please don't confuse us.

Especially do I not understand why you send messages to the
framework.aspne t group, where in you suggest that I give wrong answers in
the language.vb newsgroup, without telling in one word what the question
was.

If you are sure that my answer is wrong, than you can start a discussion
or ignore it, however telling it in other newsgroups is for me undecent.

Cor

Dec 4 '05 #7
Hi Mr. N,

Static data is singleton data. That is, there is one copy for the entire
application. There is not one copy per thread.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:en******** ********@TK2MSF TNGP12.phx.gbl. ..
Sorry, yes I meant the same thing, its an occupational hazard of switching
languages.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:e3******** *******@TK2MSFT NGP11.phx.gbl.. .
I'm a little confused by your use of the word "shared," and in the same
message, "static." In VB.Net, "shared" means "static." So, are you
referring to "shared" as in "static," or for some other meaning? If not
"static," what definition of "shared" are you meaning?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about a
couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local object
in that shared member function the system maintains a local copy of that
object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If
I have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one thread
and cannot be confused with anyone slses (UNLESS) the variable is static
as pointed out by Jay.

The reason this is making me paranoid is that I want to make extensive
used of shared functions in my data layer to reduce code bloat and
constant instantiation.

Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the
dataset would be overwritten, I cant see how this can be right. I
decided to re-do this posting thread to start afresh, I hope no one
minds.

Sorry for being a little paranoid here, but i dont want to embark upon
loads of work and then find out Im screwed!

--
Best Regards

The Inimitable Mr Newbie º¿º



Dec 4 '05 #8
Yes, I realise that. My concerns were over non static variables, I was
concerned that there may be scope for overwriting in a multi user
environment, but this was unfounded.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ue******** *******@TK2MSFT NGP12.phx.gbl.. .
Hi Mr. N,

Static data is singleton data. That is, there is one copy for the entire
application. There is not one copy per thread.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:en******** ********@TK2MSF TNGP12.phx.gbl. ..
Sorry, yes I meant the same thing, its an occupational hazard of
switching languages.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:e3******** *******@TK2MSFT NGP11.phx.gbl.. .
I'm a little confused by your use of the word "shared," and in the same
message, "static." In VB.Net, "shared" means "static." So, are you
referring to "shared" as in "static," or for some other meaning? If not
"static," what definition of "shared" are you meaning?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mr Newbie" <he**@now.com > wrote in message
news:eE******** *******@TK2MSFT NGP09.phx.gbl.. .
I'm still thinking around this subject, and I find myself unsure about
a couple of things.

When a new users launches an ASP.NET application, this must be on a new
thread. When it encounters a shared member in a class, unless you are
setting static variables presumably when you instantiate an local
object in that shared member function the system maintains a local copy
of that object per thread ( is this right ? ).

To perhaps make my point more clearly. In a shared member function, If
I have a shared member which declares a variable a of type Integer. the
actual storage of this integer I assume would be on the users one
thread and cannot be confused with anyone slses (UNLESS) the variable
is static as pointed out by Jay.

The reason this is making me paranoid is that I want to make extensive
used of shared functions in my data layer to reduce code bloat and
constant instantiation.

Does anyone see any issues with this. Cor's example in the earlier post
related to a dataset does not seem right to me as he says that the
dataset would be overwritten, I cant see how this can be right. I
decided to re-do this posting thread to start afresh, I hope no one
minds.

Sorry for being a little paranoid here, but i dont want to embark upon
loads of work and then find out Im screwed!

--
Best Regards

The Inimitable Mr Newbie º¿º



Dec 4 '05 #9
Mr. Newbie,

I simply became confused with the answers, I should have replied on the
original thread. My appologies.


Let me accept it and therefore repeat, a webapplication (is a DLL not an
Exe), is a middle tier application.

It's sharing its shared parts (even its static parts) for all users.

Therefore if you create this construction (which can be done in winforms).
\\\
Public Shared ds as dataset
Public shared sub fillmydataset(b yval clientnumber as string)
dim sqlstring as string = "Select from table where client = '" &
clientnumber & "'"
' in a lazy way of coding without parameters
'rest of the code
da.fill(ds)
end sub
///

Than every time that a client does a "fillmydataset" , the shared member ds
of the application will be overwritten. You have than therefore in my
opinion not any control about it when this will happen and cannot use that
dataset in your updates even not if you read it very quick in advance.

I hope that this gives an idea

Cor
Dec 5 '05 #10

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

Similar topics

0
2069
by: Carlos Ribeiro | last post by:
I thought about this problem over the weekend, after long hours of hacking some metaclasses to allow me to express some real case data structures as Python classes. I think that this is something with potential to be useful, but I would like to hear more opinions first. If this is deemed to be useful, I *may* try to write a PEP for it. This is not a promise or even a proposal, at this point. Broadly generalizing, classes in Python have...
3
3617
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming non-standard C++ or if the problem lies elsewhere. To summarize static const class members are not being accessed properly when accessed from a DLL by another external object file (not within the DLL). It only occurs when the static const...
1
1196
by: Bonj | last post by:
I'm having problems using static members of a class (largely HANDLEs of various sorts) as static class members of a class. It compiles OK but the linker complains of unresolved external symbol. Declaring them as just normal globals or member variables doesn't cause the said problem I've got them such a static HCURSOR g_hcWait ... MyClass::g_hcWait = LoadCursor(NULL, IDC_WAIT); //(yes I do use LoadImage really I just put that to be brief ...
11
3262
by: Mr Newbie | last post by:
I'm still thinking around this subject, and I find myself unsure about a couple of things. When a new users launches an ASP.NET application, this must be on a new thread. When it encounters a shared member in a class, unless you are setting static variables presumably when you instantiate an local object in that shared member function the system maintains a local copy of that object per thread ( is this right ? ). To perhaps make my...
2
1673
by: hdixon | last post by:
Ive spent a few days going thru a couple of Python tutorials. No problem until I got to classes. I guess my java mindset is blocking my vision. I've borrowed another thread's code snippet and cannot explain the results: class MyClass: list = myvar = 10 def add(self, x): self.list.append(x)
1
902
by: kirklarsen | last post by:
I have a class which stores some shared variables that I want to access from another project. The class is in a DLL which is being accessed using reflection in a separate appdomain. Because of this, I need to be able to have a method in another class (in the same project as the data class) which can access the class members by name. Something similar to this: Public Shared Function GetValue(ByVal name As String) As Object Return...
14
2645
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming Language, but there isn't a detail and complete description on all the class members, aren't they important to class composing? Could you explain the special class behavior in detail? Thank you very much.
10
4704
by: Joel | last post by:
Is it true that if we don't specify a default constructor for our class, then the C# compiler provides us with its own that zeroes (or assigns default values) to the data members? I wrote a no-parameter constructor for my class with an empty function body. I then instantiated an object and tried printing its values, amazingly the members were already initialized. But how is this possible if I have not included any code for doing so. The...
9
1292
by: James Turk | last post by:
Hi, I have a situation where I have some class members that should only be done once. Essentially my problem looks like this: class Base(object): dataset = None def __init__(self, param): if type(self).dataset is None:
0
9566
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
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
10317
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
10069
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
9127
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...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
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.