473,406 Members | 2,343 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,406 software developers and data experts.

"Shared" Methods in asp.net files/classes

I know that one of the benefits of using "Shared" methods
is you do not explicitly have to Dim as New object to
access the method.

Are there some other implications with memory and
concurrency issues with lets say 25-50 concurrent users?

What are the pros and cons of using this type of method?

Thanks so much,

Jenna Schmidt
Nov 17 '05 #1
2 1610
PJ
The pro is that you can share singular instances of objects with multiple
threads/users.
The con is that you can share singular instances of objects with multiple
threads/users.

Shared/Static methods/properties are an easy way to cache data and a good
way to create helper type classes, but you must be careful to write thread
safe code when sharing state data in these methods/properties.

"Jenna Schmidt" <je***@nospam.artifextech.com> wrote in message
news:03****************************@phx.gbl...
I know that one of the benefits of using "Shared" methods
is you do not explicitly have to Dim as New object to
access the method.

Are there some other implications with memory and
concurrency issues with lets say 25-50 concurrent users?

What are the pros and cons of using this type of method?

Thanks so much,

Jenna Schmidt

Nov 17 '05 #2
Jenna, often choosing shared members is done becuase its nicer to program
against. Consider the Environment class, which only has statics. It has a
lot fo related methods on it, but really, you're not generally going to be
manipulating 10 of those methods at the same time, but instead, you're going
to be using one at a time. In this scenario, its nice to not have to dim up
anew version of the class. The same goes for the Math class, and other
classes also.

Other times, it's just good sense. Consider this code:

Dim dt as DateTime = new DateTime()
dt = dt.Now()

That code really doesn't look that good, since Now() is NOTHING to do with
an instance, but specifically, is related to a concept independent of each
inidividual DateTime. which is why we instead do:

Dim dt as DateTime = DateTime.Now()

The key thing is, use shared members when data or functionality does not
vary on an instance by instance basis.

Regards,
Kit

"Jenna Schmidt" <je***@nospam.artifextech.com> wrote in message
news:03****************************@phx.gbl...
I know that one of the benefits of using "Shared" methods
is you do not explicitly have to Dim as New object to
access the method.

Are there some other implications with memory and
concurrency issues with lets say 25-50 concurrent users?

What are the pros and cons of using this type of method?

Thanks so much,

Jenna Schmidt

Nov 17 '05 #3

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

Similar topics

2
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
6
by: Ross | last post by:
MyWebProject.MyWebForm1.someset.somedata is a datatable within a dataset. Displays quite nicely, too. Now I want to use the same data in MyWebProject.MyWebForm2. Being a old, er, experienced Java...
3
by: Henri | last post by:
Hi, Sorry for my bad English. Could you tell me if the context of a member declared as Shared is limited to the instance of the page the object that owns this member is declared in, or does it...
2
by: John Granade | last post by:
I'm looking for the best way to make a dataset available from multiple Windows forms. The dataset is created from an XML file. I have a main form (frmMain) that loads the dataset and reads the...
1
by: David Sanschagrin | last post by:
(I previously posted this problem on vb.general.discussion but I've been told that this question is more related to VB.NET than VB6 and so that I should post that here.) I'm trying to call a...
2
by: HmFireBall | last post by:
Hi, This is a question about a shared property in ASP.NET Imagine there's an assembly called my.dll that is in the /bin directory of several websites. This assembly contains a class with a...
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
3
Markus
by: Markus | last post by:
I've changed between XAMPP and EasyPHP, and the error occurs on both. I know the PHP is being processed because if I do something like a header() redirect, it'll redirect to the page, but then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
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...
0
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...

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.