473,322 Members | 1,523 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,322 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 1243

"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

0
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...
3
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...
1
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....
11
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...
2
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...
1
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...
14
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...
10
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...
9
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):...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.