守护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);
        }
    });
}
posted @ 2020-11-12 16:43  Jonny-Xhl  阅读(207)  评论(0编辑  收藏  举报