This is a multi-part question.
I have a process that can take several minutes to complete, it is ran by a calling a HTTPHandler using a asynchronous javascript request.
Question 1: How can I ensure that this request does not time out on both the server and the client?
Question 2: Is it possible to emit data from the HTTPHandler while processing that is sent back to the XmlHttpRequest object before the final page is completed?
I'd like to calculate actual workload and return percentage done. I'm guessing that this is possible.
Any tips?
EDIT:
A quick test:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
for (int i = 0; i < 100; i++)
{
context.Response.Write("Hello World " + i + Environment.NewLine);
System.Threading.Thread.Sleep(500);
context.Response.Flush();
}
}
Pushes Hello World bit by bit to the client...This works on a synchronious request, I'll see if a xmlHttpRequest gets a readystatechange event for each line.
I've always avoiding multithreading on ASP.NET apps because you don't have control of when the working process will die, which will result in all of its spawned threads dieing.
Instead, why re-invent a separate thread pool when IIS is already doing this for you.