Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET 2.0 Asynchronous User Control Not Working
    text
    copied!<p>I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:</p> <pre><code>&lt;%@ Control Language="C#" %&gt; &lt;script runat="server"&gt; SqlConnection m_oConnection; SqlCommand m_oCommand; void Page_Load(object sender, EventArgs e) { Trace.Warn("Page_Load"); string strDSN = ConfigurationManager.ConnectionStrings["DSN"].ConnectionString + ";async=true"; string strSQL = "waitfor delay '00:00:10'; select * from MyTable"; m_oConnection = new SqlConnection(strDSN); m_oCommand = new SqlCommand(strSQL, m_oConnection); m_oConnection.Open(); Page.RegisterAsyncTask(new PageAsyncTask(new BeginEventHandler(BeginHandler), new EndEventHandler(EndHandler), new EndEventHandler(TimeoutHandler), null, true)); Page.ExecuteRegisteredAsyncTasks(); } IAsyncResult BeginHandler(object src, EventArgs e, AsyncCallback cb, object state) { Trace.Warn("BeginHandler"); return m_oCommand.BeginExecuteReader(cb, state); } void EndHandler(IAsyncResult ar) { Trace.Warn("EndHandler"); GridView1.DataSource = m_oCommand.EndExecuteReader(ar); GridView1.DataBind(); m_oConnection.Close(); } void TimeoutHandler(IAsyncResult ar) { Trace.Warn("TimeoutHandler"); } &lt;/script&gt; &lt;asp:gridview id="GridView1" runat="server" /&gt; </code></pre> <p>And this would be the page in which I host the control three times:</p> <pre><code>&lt;%@ page language="C#" trace="true" async="true" asynctimeout="60" %&gt; &lt;%@ register tagprefix="uc" tagname="mycontrol" src="~/MyControl.ascx" %&gt; &lt;html&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;uc:mycontrol id="MyControl1" runat="server" /&gt; &lt;uc:mycontrol id="MyControl2" runat="server" /&gt; &lt;uc:mycontrol id="MyControl3" runat="server" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The page gets displayed without errors, but the trace at the bottom of the page shows each control instance is processed synchronously. What am I doing wrong? Is there a configuration setting somewhere I'm missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload