How do I use IHTTPAsyncHandler?
1 answer
I recently added some asynchronous processes to my ASP.NET pages to allow some long running processes while the user was waiting for results. I found the IHTTPAsyncHandler to be pretty inadequate. All it does is let you spin a new thread while the page starts processing. You should still create your own thread and create an AsyncRequestResult.
Instead, I ended up using the normal stream in my code instead, much more concise:
using System;
using System.Web;
using System.Threading;
namespace Temp {
public partial class thread : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
Thread thread = new Thread(new ThreadStart(myAsyncProcess));
thread.Start();
}
private void myAsyncProcess() {
// Long running process
}
}
}
-2
source to share