1

I have an IIS application that has a long-lived singleton. On rare occasion, this singleton hangs when trying to obtain a resource. It is known that recycling the application pool will cause the resource to became available again. Assuming this rare event can be trapped by the application itself using a StopWatch or similar, upon doing so, can the event handler in the application itself recycle the application pool? This is a severe thing to do, but it is better than letting it hang until the next IIS scheduled recycling. The cause of the hang is related to that resource and its interaction with IIS, and I have no means to fix that. Note the call to get the resource is synchronous. If so, please provide information about how to do so.

Response to comments Regarding Restarting the Application Domain and Recycling the Application Pool my observations are that restarting the Application Domain is one of the causes of the hang. The resource is an unruly native dll that is loaded by code other than my own. Perhaps I find an API to unload and load the unruly unmanaged dll. But for now, I have been manually, not programmatically, recycling the application pool to restore operations.

Upon Recycling the Application Pool, the Destructor of the Singleton is called, and therein the resource, after a call to the external API, Dispose(), is put into a good state, presumably unloaded, but I have yet verify that.

Community
  • 1
  • 1
subsci
  • 1,740
  • 17
  • 36
  • You have already ruled out recycling the app domain? – AnotherDeveloper Aug 26 '15 at 19:01
  • 1
    possible duplicate of [Restarting (Recycling) an Application Pool](http://stackoverflow.com/questions/249927/restarting-recycling-an-application-pool) – Cory Charlton Aug 26 '15 at 19:09
  • @CoryCharlton Yes this may be a duplicate, but I think this one may be different, please let me know, because it asks about an Application recycling its parent Pool, rather than a third party doing so. Please help me understand. Should I just try to have my Application recycle the Application Pool and see how that works? – subsci Aug 26 '15 at 20:39
  • @subsci Yes I would try to implement the code shown in that example to restart the application pool. That said as @Jason mentioned recycling the app domain is probably easier and might fit your needs. Also from the linked possible duplicate: `HttpRuntime.UnloadAppDomain();` – Cory Charlton Aug 26 '15 at 20:45

0 Answers0