I have a .NET WCF application that I am hosting through IIS and I want to know how/where/when to execute some code when the application pool is stopped/restarted. Basically, I keep track of some statistics of use of my web service but I bunch the updates
to the db concerning these statistics into batches so that I am not making an extra call to the db for each request. I just have a Timer on an interval of 5 minutes and make my updates then. But, I'm wondering how to handle IIS recycling. I
know I could just turn it off for this particular application pool, since my code is all managed and I've read several places that recycling app pools is really about sweeping memory leak problems under the carpet. However, I would still like to know
how to handle IIS recycling. My first (and only) idea was to handle the db updates in the destructor of a singleton. I was quite sure this was would work brilliantly. However, I kept getting errors, and, come to find out, you can't use db
connections in a destructor. DOH! So, now, I'm lost. Any ideas?
View Complete Post