Knowing when IIS is recycling

Hello,
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?
Thanks,
Jeromeyers

More Related Resource Links

My web application has user control which uses third party controls called Devexpress controls. The user control is a menu and is part of the Master page. It is placed there because this needs to be available in all the pages. My user controls raises a even on item clicked. Now, My question is that Is there any way to know that the event has occurred in page_load of the current page in which I am in?

Hello,
How do I get the ordinal position of a control without knowing, and more importantly, not needing to know it's parent type?
For example, this XMAL:
<Parent of unknown type>
<Control Name="Control_1" />
<Control Name="Control_2" />
<Control Name="Control_3" />
<Control Name="Control_4" />
</Parent of unknown type>
How do I get "Control_3"s ordinal position within its parent control?
I know that I can do this:
UIElement p = (UIElement)Control_3.Parent;
or even:
FrameworkElement p = (FrameworkElement)Control_3.Parent;
but neither of those allow:
int i = p.Children.IndexOf(Control_3);
nor
int i = p.Items.IndexOf(Control_3);
If the parent is a StackPanel, I can do:
StackPanel p = (StackPanel)Control_3.Parent;
and then I can do:
int i = p.Children.IndexOf(Control_3);
I really do not want to have to cast the parent to a specific type, that would be a pain since there several types that could have children or items.
Regards,
Robert

Hello, we are currently doing some performance tests for our WCF services running on IIS 7. Performance is as expected with moderate CPU and memory usage (CPU usage less than 40%). We are facing a problem when IIS recycles a worker process: After the recycle
the throughput drops by about 1/2 with multiple times longer response times.

Some details about the setup:

Dedicated machine for performance testing, no other services installed

Services used by tested services are installed on a second, dedicated machine as mock services

The problem is significant for services that use other services using WCF (i.e. tested services are both, server and client)

The service parallelizes requests to a WCF mock service on the second machine (about 8 outgoing requests per incoming request)

we're hosting a webservice that runs with up to 9 worker processes in it's application pool. There's a memory limit configured for the application pool to keep the system/server performant. Now my concern is that, if the memory limit is reached, a worker process may be recycled although there is an active request handled by this worker process that needs to be responded/finished first. The problem is especially with purchase/order requests, as such requests typically run several minutes and must not be aborted by any worker process recycle process. Is there any configuration setting that allows me app pool recycling by granting that no active process will be abandoned? Any advice appreaciated!

I have a feature that creates a list and publishes a webpart. The webpart has a LookupField webcontrol on it that needs to point to the List that the feature is creating. How can I do this without programmatically creating the LookupField webcontrol?
Is that the only way?