Perfect Singleton with Semaphore?

  • Thread starter Thread starter lucius
  • Start date Start date
L

lucius

Can anyone show a code sample of a "perfect Singleton" that uses the
Semaphore class in Framework 2.0? I have a security-related class that
I would like to code as a Singleton, and re-use it in both ASP.NET and
WinForms. I understand that these are very differnet environments when
it comes to threading and etc, so any/all help is appreciated.


Thanks.
 
Hello lucius,

See there http://www.codeproject.com/dotnet/remotingsingleton.asp

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

l> Can anyone show a code sample of a "perfect Singleton" that uses the
l> Semaphore class in Framework 2.0? I have a security-related class
l> that I would like to code as a Singleton, and re-use it in both
l> ASP.NET and WinForms. I understand that these are very differnet
l> environments when it comes to threading and etc, so any/all help is
l> appreciated.
l>
l> Thanks.
l>
 
Hi Lucius,

For implementing singleton Pattern and mutlti-threading awared issue, Here
is a article from MSDN:

#Exploring the Singleton Design Pattern
http://msdn2.microsoft.com/en-us/library/ms954629.aspx

Also, for making singleton thread-safe(in multi-threading context), you can
find many web articles discussing on this:

http://en.csharp-online.net/Singleton_design_pattern:_Thread-safe_Singleton

http://aspadvice.com/blogs/oliviers_net_blog/archive/2006/07/25/Thread-safe-
singleton-pattern-with-C_23003A00_-easy_2100_.aspx

http://bloggingabout.net/blogs/rick/archive/2005/09/21/9494.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top