守护IIS进程
private void ListenApplicationPool()
{
var manager = new Microsoft.Web.Administration.ServerManager();
System.Threading.ThreadPool.QueueUserWorkItem((state) =>
{
while (true)
{
var pools = manager.ApplicationPools;
foreach (var pool in pools)
{
if (pool.State == Microsoft.Web.Administration.ObjectState.Stopped)
{
pool.Start();
}
}
System.Threading.Thread.Sleep(2000);
}
});
}