Reputation: 559
If I just run one of the async events everything executes exactly as it should be. However, when I add in all 3 of my events, I get (from what I gather) a timeout from my syntax. Here is a full stack-trace that will hopefully assist.
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object..
at System.Web.UI.Page.d__554.MoveNext()
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.d__554.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.UI.Page.AsyncPageEndProcessRequest(IAsyncResult result)
at ASP.pages_AsyncTest1_aspx.EndProcessRequest(IAsyncResult ar) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\14a1541c\96dbdee3\App_Web_AsyncTest1.aspx.f9b0821e.cqtg2bnc.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Exception type: System.Web.HttpUnhandledException
Message : Exception of type 'System.Web.HttpUnhandledException' was thrown.
Stacktrace:
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.d__554.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.UI.Page.AsyncPageEndProcessRequest(IAsyncResult result)
at ASP.pages_AsyncTest1_aspx.EndProcessRequest(IAsyncResult ar) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\14a1541c\96dbdee3\App_Web_AsyncTest1.aspx.f9b0821e.cqtg2bnc.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
And here is the C# syntax I want to execute:
namespace CEDS
{
public partial class BBLL : System.Web.UI.UserControl
{
private DataSet DS = new DataSet();
private DataSet DS1 = new DataSet();
private DataSet DS2 = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Page.RegisterAsyncTask(new PageAsyncTask(RunSQLUSP));
}
}
public async System.Threading.Tasks.Task RunSQLUSP()
{
var t1 = GetDataForDropDown1();
var t2 = GetDataForDropDown2();
var t3 = GetDataForDropDown3();
//This line is hit then error is thrown
await System.Threading.Tasks.Task.WhenAll(t1, t2, t3);
//Bind Data to grids/dropdowns
}
}
}
async System.Threading.Tasks.Task<DataSet> GetDataForDropDown1()
{
DS = GetDataForDropDown1();
return DS;
}
async System.Threading.Tasks.Task<DataSet> GetDataForDropDown2()
{
DS2 = GetDataForDropDown2();
return DS2;
}
async System.Threading.Tasks.Task<DataSet> GetDataForDropDown3()
{
DS = GetDataForDropDown3();
return DS;
}
Upvotes: 6
Views: 6066
Reputation: 765
Refer to this answer.
You need to set the AsyncTimeout property on your aspx. The reason for the exception is that your asynchronous operation exceeded the current AsyncTimeout value which I'm guessing is in default. The value should be in milliseconds.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BBLL.aspx.cs" Inherits="Sample03.Default" Async="true" AsyncTimeout="600000" %> //10 mins
Upvotes: 9