Reputation: 801
I have a ASP.NET MVC web application deployed on IIS server,
In that app, I do a thing such like below in a independent thread:
while (true)
{
doSomeJobs();
Thread.Sleep(TimeSpan.FromMinutes(5));
}
Start this thread in Application_Start()
so seems it will never stop only sleep for 5 minutes between every round of job.
First looks work well but in the next day I check the log it's not working as I expect, it's been stopped working for a very long time.
Then when I send a request again to the app, it begins to work again.
So what did I miss up? Is it possible to make a thread working in the background in every specific time even without any request to the app? Such like a scheduled task ?
Upvotes: 4
Views: 1512
Reputation: 801
Finally I found this a common issue,
That's because IIS will stop your process in the specific time if nobody requests to your app.
To keep your app alive.
Upvotes: 2