It is an ASP.NET MVC website. I add some log in the Application_end method.
I know there are some circumstances when the Application_end will be called, such as application pool's recycle, web.config file's change, or bin file's change. But my problem here is very weirdly.The Application_end methon in my ASP.NET MVC website is called many times weirdly almost at the same time.
Here is my code:
protected void Application_end()
{
FileLog.Info("The website is starting to quit...", LogType.Info);
PersistentService.RunSignal = false;
//To wait for pesistent action finish
Task.WaitAll(_tasks.ToArray(), 1000 * 300);
FileLog.Info("The website finish quit...", LogType.Info);
}
You can see, the Application_end is called 4 times in the same second. I guess, it can be called one time if the application pool is recycled at that time, but why 4 times?
Could anyone help? Thanks.
Edit: I notice that my application pool is with 5 worker processes at max. Is every work process's end will call Application_end method?