守护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);
        }
    });
}

守护IIS进程

原文地址:https://www.cnblogs.com/cqxhl/p/13964716.html

为您推荐