473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 3231

"Mr Newbie" <he**@now.com> wrote in message
news:eE***************@TK2MSFTNGP09.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" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:ei****************@TK2MSFTNGP12.phx.gbl...

"Mr Newbie" <he**@now.com> wrote in message
news:eE***************@TK2MSFTNGP09.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***************@TK2MSFTNGP09.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.aspnet
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:e3***************@TK2MSFTNGP11.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***************@TK2MSFTNGP09.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******************@TK2MSFTNGP10.phx.gbl...
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.aspnet 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****************@TK2MSFTNGP12.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:e3***************@TK2MSFTNGP11.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***************@TK2MSFTNGP09.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ue***************@TK2MSFTNGP12.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****************@TK2MSFTNGP12.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:e3***************@TK2MSFTNGP11.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***************@TK2MSFTNGP09.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(byval 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
Thanks for your help.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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(byval 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 #11
Ah, I misunderstood.

--
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:u5***************@TK2MSFTNGP12.phx.gbl...
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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ue***************@TK2MSFTNGP12.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****************@TK2MSFTNGP12.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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:e3***************@TK2MSFTNGP11.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***************@TK2MSFTNGP09.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 5 '05 #12

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

Similar topics

10
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...
11
by: tshad | last post by:
I am setting up some of my functions in a class called MyFunctions. I am not clear as to the best time to set a function as Shared and when not to. For example, I have the following bit...
11
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
15
by: Rob Nicholson | last post by:
A consequence of the ASP.NET architecture on IIS has just hit home with a big thud. It's to do with shared variables. Consider a module like this: Public Module Functions Public GlobalName As...
1
by: daFou | last post by:
Please help me how to access shared members in my global.asax in ASP.NET 2.0 This is what i do. First I create a new website using VS.NET 2005. I select a location where the website should be...
1
by: Edward | last post by:
I have trouble with some of the concepts of OOP, and am struggling currently with Private Shared Functions. I think I understand Private (not available outside the class). I think I understand...
5
by: Erik Cruz | last post by:
Hello! I have read some threads discussing the fact that a module is in reality a shared class. If I try to create a Public Shared Class in vb.net I receive a compile error. Why? If I can't...
4
by: a | last post by:
Hello Gang, I am in a bit of confusion regarding a half completed application I am writing. It is an MDI app, so I have a main form (frmMain) that is always open. I am looking for a 'Best...
6
by: Daniel Fernandes | last post by:
Hi there Is there any difference I need to be aware when I create a class with only shared members & procedures when compared to a module (which is a shared class) ? I am asking this because...
8
by: gemel | last post by:
I have been reading sime material in .NET that throws some doubt on my understanding of shared procedures. With regard to object programming I assumed that variables declared within a class were...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.