Applying the Singleton Design Pattern in .NET Remoting
page 4 of 5
by Joseph Chahine
Feedback
Average Rating: 
Views (Total / Last 10 Days): 22746/ 70

Notes

For many applications the Singleton Design Pattern approach works fine.  However, for multithreaded applications this approach proves to have a potentially hazardous side effect.  If two threads manage to enter the control block at the same time, two instances of the member variable could be created.  To solve this you might be tempted to merely place a critical section around the control block in order to guarantee thread safety.

However, ASP.NET runs each incoming request on its own separate worker thread.  The ASP.NET programming model is based on a scheme in which each worker thread is routed through a private set of ASP.NET objects, including applications, modules, pages, and custom handlers.  The ASP.NET programming model was designed to ensure that only one worker thread will ever touch any one of these objects at any one time.  This enhances productivity because you can write most of your ASP.NET code as single-threaded.  There is no need to worry about concurrency or thread safety for the scenario described in this article.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-07 7:42:45 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search