无法检测App池回收

时间:2018-06-14 10:40:38

标签: c# asp.net application-pool

在我的应用程序中,我需要检测应用程序池回收事件。我已在应用程序池设置中将关闭时间限制设置为10秒,然后按this应答以检测回收事件。

  

1)创建一个实现IRegisteredObject

的类
public class HostingEnvironmentRegisteredObject : IRegisteredObject
{
    // this is called both when shutting down starts and when it ends
    public void Stop(bool immediate)
    {
        if (immediate)
            return;

        // Log something
        // there will about Shutting down time limit seconds to do the work
    }
}
     

2)注册你的对象(Global.asax.cs)

protected void Application_Start()
{
    // other initialization code here

    HostingEnvironment.RegisterObject(new HostingEnvironmentRegisteredObject());
}

但显然,该事件不会在应用程序池回收中被解雇,因为日志中没有写入任何内容。但是,如果我停止应用程序池,我可以看到添加了日志。因此,该事件将因应用程序池停止而被解雇,而不是用于回收。

我错过了什么吗?

0 个答案:

没有答案
相关问题