| Article: |
ADO.NET Connection Pooling Explained | |
| Subject: | Slightly bad advice | |
| Date: | 2004-02-25 08:00:49 | |
| From: | asills | |
|
While the technique provided here is definitely valid, one huge thing you missed is I would probably bet that a lot of novice web developers will take this code as is and use it in their web applications, without realizing the multi-threaded problems that might arise when using this code.
|
||
Showing messages 1 through 1 of 1.
-
Slightly bad advice
2004-04-15 22:58:50 AndrewG [View]



You're right in saying ASP.NET is multi-threaded, but each request comes in on it's own thread and is seviced by a unique application instance. This means you don't have to concern yourself with MT issues - simply because all variables are local to your application instance. ASP.NET application objects are pooled and removed/returned to the pool upon each request/reply.
Shared/static variables will require protection from concurrent access. This is due to shared/static variables being maintained at the AppDomain level and not the Application level.
In the example of connection pooling a simple non-shared/static variable in the application object (initialized with the pool count) would be sufficient