Hi
I have a report that takes about 2 or 3 minutes to pull all the data
So I am trying to use ASP.net Asynch pages to prevent a timeout. But can't get it to work
Here's what I am doing :
private delegate List<PublishedPagesDataItem> AsyncReportDataDelegate();
private AsyncReportDataDelegate longRunningMethod;
private List<PublishedPagesDataItem> reportData;
public PublishedPagesReport() // this is the constructor
{
reportData = new List<PublishedPagesDataItem>();
longRunningMethod = GetReportData;
}
protected void Page_Load(object sender, EventArgs e)
{
this.PreRenderComplete +=
new EventHandler(Page_PreRenderComplete);
AddOnPreRenderCompleteAsync(
new BeginEventHandler(BeginAsynchOperation),
new EndEventHandler(EndAsynchOperation)
);
}
private List<PublishedPagesDataItem> GetReportData()
{
// this is a long running method
}
private IAsyncResult BeginAsynchOperation(object sender, EventArgs e, AsyncCallback cb, object extradata)
{
return longRunningMethod.BeginInvoke(cb, extradata);
}
private void EndAsynchOperation(IAsyncResult ar)
{
reportData = longRunningMethod.EndInvoke(ar);
}
private void Page_PreRenderComplete(object sender, EventArgs e)
{
reportGridView.DataSource = reportData;
reportGridView.DataBind();
}
So I have a delegate representing the Long running method (GetReportData).
And I am trying to call it as per this article :
http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
The long running method does complete in the debugger but breakpoints on the EndAsynchOperation and Page_PreRenderComplete methods never get hit
any idea what I am doing wrong?