Hi everyone, what would happen if I spin off a thread to execute a long-running process right before the ASP.NET page lifecycle completes? Will the ASP.NET runtime kill the thread? Can this lead to undefined behaviour?
Here's a sample of the code, which spins the background thread in the Page_Load event. Is this a safe thing to do?
protected void Page_Load(object sender, EventArgs e)
{
Thread newThread = new Thread(new ThreadStart(SomeLongRunningMethod));
newThread.IsBackground = true;
newThread.Start();
}
private void SomeLongRunningMethod()
{
// some long running process goes here...
}