> I have inherited a Business Object architecture that makes heavy use
> of the Singleton design patter. For example the data access layer
[quoted text clipped - 12 lines]
> instantiation will guerantee that each web app thread will have its
> own static variables.
Well, firstly I'd say it no longer counts as a singleton - a factory,
more like.
It would be simpler just to use the ThreadStatic attribute, to be
honest, but I dare say it'll work.
However, you *do* need to be careful of ASP.NET thread agility. In some
situations (and it's version-dependent) a request can hop around
multiple different threads during its lifetime. If it's important that
you use a single ConnectionManager for all the different parts of the
life cycle, you'll need to rethink this.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
koredump - 19 Jul 2007 14:41 GMT
Thanks for that Jon. But...
>In situations (and it's version-dependent) a request can hop around
> multiple different threads during its lifetime.
My understanding of how the aspnet worker process works is as follows:
There is a pool of threads that serves all the web requests.
Once a thread is assigned to process a web request it's removed fromt the
threadpool, it then processes the web request from start to finish. After it
is done with the web request, the thread is return to the thread pool.
Are you saying that one thread could be serving multiple requests at the
same exact time?
Jon Skeet [C# MVP] - 19 Jul 2007 21:30 GMT
> Thanks for that Jon. But...
>
[quoted text clipped - 8 lines]
> Are you saying that one thread could be serving multiple requests at the
> same exact time?
I'm saying that parts of the same web request's lifecycle can occur on
different threads in some situations, at least with ASP.NET 1.1.
I was investigating this recently and posted my results on a discussion
topic: see http://forum.springframework.net/showthread.php?t=572

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too