Some questions coming from application programming (C#/Visual C++) to ASP.NET (C#)
<p>At the new place I am working, I've been tasking with developing a web-application framework.  I am new (6 months ish) to the ASP.NET framework and things seem pretty straight forward, but I have a few questions that I'd like to ask you ASP professionals.  I'll note that I am no stranger to C#.</p>

<p><strong>Long life objects/Caching</strong></p>

<p>What is the preferred method to deal with objects that you don't want to re-initialize every time a page is it?  I noticed that there was a cache manager that can be used, but are there any caveats to using this?  For example, I might want to cache various things and I was thinking about writing a wrapper around the cache that prefixed cache names so that I could implement different caches using the same underlying .NET cache manager.  </p>

<p>1) Are there any design considerations I need to think about the objects that I am want to cache?</p>

<p>2) If I want to implement a manager of some time that is around during the lifetime of the web application (thread-safe, obviously), is it enough to initialize it during app_start and kill it in app_end?  Or is this practiced frowned upon and any managers are created uniquely in the constructor/init method of the page being served.</p>

<p>3) If I have a long-term object initialized at app start, is this likely to get affected when the app pool is recycled?  If it is destroy at app end is it a case of it simply getting destroyed and then recreated again?  I am fine with this restriction, I just want to get a little clearer :)</p>

<p><strong>Long Life Threads</strong></p>

<p>I've done a bit of research on this and this question is probably redundant.  It seems it is not safe to start a worker thread in the ASP.NET environment and instead, use a windows service to do long-running tasks.  The latter isn't exactly a problem, the target environments will have the facility to install services, but I just wanted to double check that this was absolutely necessary.  I understand threads can throw exceptions and die, but I do not understand the reasoning behind prohibiting them.  If .NET provided a a thread framework that encompassed System.Thread, but also provided notifications for when the Application Server was going to recycle the App-Pool, we could actually do something about it rather than just keel over and die at the point we were stopped.</p>

<p>Are there any solutions to threading in ASP.NET or is it basically "service"?</p>

<p>I am sure I'll have more queries, but this is it for now.</p>

<p>EDIT: Thankyou for all the responses!</p>
