473,769 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is my choice in this situation? Thanks.

I created my own WebControl, I am thinking a way to put some logics in the
class to a seperated class, and it will be accessed by all instances of my
WebControl, the idea is that the class doesn;t need to be created everytime,
and data in it can be retrieved from database one time only. What can I
achieve this? static method in class? multi-thread class? or cache?
Thanks
Nov 15 '05 #1
3 1126
make it singleton and put into the cache

something like

public class CachedLogic
{
private static CachedLogic m_instance;

public static CachedLogic Instance
{
get
{
if ( m_instance == null)
m_instance = new CachedLogic();
return ( m_instance );
}
}
}

And then in the Web page or in the Web Service you can use Application cache
e.g
CachedLogic logic;
logic = Application["MyCachedLo gic"] ;
if ( logic == null )
{
logic = CachedLogic.Ins tance;
this.Applicatio n["MyCachedLo gic"] = logic;
}

"davidw" <da****@affinis ys.com> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl...
I created my own WebControl, I am thinking a way to put some logics in the
class to a seperated class, and it will be accessed by all instances of my
WebControl, the idea is that the class doesn;t need to be created everytime, and data in it can be retrieved from database one time only. What can I
achieve this? static method in class? multi-thread class? or cache?
Thanks

Nov 15 '05 #2

"Vadym Stetsyak" <pd****@ukr.net > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
make it singleton and put into the cache

something like

public class CachedLogic
{
private static CachedLogic m_instance;

public static CachedLogic Instance
{
get
{
if ( m_instance == null)
m_instance = new CachedLogic();
return ( m_instance );
}
}
}

And then in the Web page or in the Web Service you can use Application cache e.g
CachedLogic logic;
logic = Application["MyCachedLo gic"] ;
if ( logic == null )
{
logic = CachedLogic.Ins tance;
this.Applicatio n["MyCachedLo gic"] = logic;
}

"davidw" <da****@affinis ys.com> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl...
I created my own WebControl, I am thinking a way to put some logics in the class to a seperated class, and it will be accessed by all instances of my WebControl, the idea is that the class doesn;t need to be created

everytime,
and data in it can be retrieved from database one time only. What can I
achieve this? static method in class? multi-thread class? or cache?
Thanks


Nov 15 '05 #3
Vadym Stetsyak <pd****@ukr.net > wrote:
make it singleton and put into the cache

something like

public class CachedLogic
{
private static CachedLogic m_instance;

public static CachedLogic Instance
{
get
{
if ( m_instance == null)
m_instance = new CachedLogic();
return ( m_instance );
}
}
}


That's not a thread-safe singleton pattern - there are simpler patterns
which *are* thread-safe, however. See
http://www.pobox.com/~skeet/csharp/singleton.html

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4

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

Similar topics

220
19152
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
86
7799
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that: http://www.clagnut.com/blog/348/ I hope that's going to be a good discussion! Michael
12
3304
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. Such things happen. The whole subsystem is going through radical changes. I don't really want to say what I think of the code just yet. That would influence the opinions of others, and I really want to know how other people view these things,...
46
4255
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do believe MSFT should do to improve C#, however. I know that in the "Whidbey" release of VS.NET currently
41
3435
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
13
5058
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
8
3184
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that basically entitled to us to just about every .Net development tool you can imagine. I cant even begin to mention them. To begin with, my background is not that of a programmer, but a systems engineer and the closest I have come to "programming"...
669
26191
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
1
1360
by: Thijs | last post by:
Hej, I want to achieve the following situation: <mytag>foo</mytag> or: <mytag><other ref="bar"/></mytag> So mytag contains either text (simplecontent) or the other element.
0
9579
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7404
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
6662
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();...
0
5294
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
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.