Reputation: 630
I have a ASP.Net Web Forms application that calls a WCF service hosted on IIS via a button click event inside a Ajax Update panel. When I click the button I call a WCF Async process that can take over 1 minute to return. I've noticed when the task is running and I open another tab in my browser the web page freezes/clocks until the long running task returns. I assume that the first task is locking the UI thread causing anyone else to use the web page to have to wait.
How can I run a task, update the UI with the results and not block the UI for other Tabs/Users?
Here is a snipit of code:
protected void btnsearch_ServerClick(object sender, EventArgs e)
{
Page.RegisterAsyncTask(new PageAsyncTask(async () =>
{
DataSet ds;
ds = await data.GetReportAsync();
grdsummary.DataSource = ds.Tables[0];
grdsummary.DataBind();
}));
}
I did try adding .ConfigureAwait(false) to the Async call but that didn't do anything.
Upvotes: 1
Views: 970
Reputation: 456437
I assume that the first task is locking the UI thread causing anyone else to use the web page to have to wait.
This is ASP.NET; there's no UI thread.
Most likely, what is happening is that the session state is preventing multiple simultaneous requests.
Note that multiple users will not be affected; only multiple requests in the same session will be seiralized.
Upvotes: 2
Reputation: 13
Registering is one thing, Executing is one another :)
Just add an ExecuteRegisteredAsyncTasks call after and it should work fine, or please add the code where this call is done.
protected void btnSearch_Click(object sender, EventArgs e)
{
Page.RegisterAsyncTask(new PageAsyncTask(async () =>
{
grdsummary.DataSource = await getSomeDataAsync();
grdsummary.DataBind();
}));
Page.ExecuteRegisteredAsyncTasks();
}
Upvotes: 0