我们有一个应用程序收集计数器统计信息,我们希望在执行iisreset命令后重置值,这就是全部.
微软表示Application_Start:
在请求ASP.NET应用程序中的第一个资源(例如页面)时调用.在应用程序的生命周期中, Application_Start方法仅被调用一次.您可以使用此方法执行启动任务,例如将数据加载到缓存中以及初始化静态值.
这就是我们目前的做法:
protected void Application_Start(object sender, EventArgs e)
{
_counters.Get<AutoCounter>("TAS:RequestCount").Reset();
_counters.Get<AutoCounter>("TAS:RequestTime").Reset();
_counters.Get<AutoCounter>("TAS:TimeBetweenErrors").Reset();
_counters.Get<AutoCounter>("TAS:ErrorCount").Reset();
}
Run Code Online (Sandbox Code Playgroud)
但是,它们会以意外的间隔重置.什么决定应用程序域的生命周期何时结束,并在下一个请求中调用此方法?