I have a PageAsyncTask that takes about 2 mins to run. My page directive has Async="true", my config has the timeout as 180 (3 mins to give extra time), but when I call Page.ExecuteRegisteredAsyncTasks() it doesn't come back right away and is blocking while it's running the task.
Am I missing any steps to get this to run asynchronously?
(this was formatted better but after edit it screwed it all up)
// in my button click event
MyTask task = new MyTask();
PageAsyncTask asyncTask = new PageAsyncTask(task.OnBegin, task.OnEnd, task.OnTimeout);
Page.RegisterAsyncTask(asyncTask);
Page.ExecuteRegisteredAsyncTasks();
// MyTask.cs
public class MyTask
{
protected delegate void AsyncTaskDelegate();
private AsyncTaskDelegate dlgt;
public void Run() { // my code that hits DB }
public IAsyncResult OnBegin(object sender, EventArgs e, AsyncCallback cb, object extra)
{
dlgt = new AsyncTaskDelegate();
IAsyncResult result = dlgt.BeginInvoke(extra, cb, null);
return result;
}
}