如何在ASP.NET WebForms中使用BackgroundWorker

如何在ASP.NET WebForms中使用BackgroundWorker,asp.net,sql,multithreading,webforms,Asp.net,Sql,Multithreading,Webforms,在ASP.NET WebForms中 如何在后台运行sql命令并仍然使用控件,用户界面在命令返回结果之前不会冻结…我了解了Windows应用程序中的BackgroundWorker..如何在asp.net webForms中使用它..只需在DoWork()中键入要在后台运行的代码并调用runworkerasync() 对于后台的sql命令,可以使用UpdatePanel异步运行代码。 ASPX页面标记: <asp:ScriptManager ID="sm" runat="server" /

在ASP.NET WebForms中


如何在后台运行sql命令并仍然使用控件,用户界面在命令返回结果之前不会冻结…我了解了Windows应用程序中的BackgroundWorker..如何在asp.net webForms中使用它..

只需在DoWork()中键入要在后台运行的代码并调用runworkerasync()


对于后台的sql命令,可以使用UpdatePanel异步运行代码。 ASPX页面标记:

<asp:ScriptManager ID="sm" runat="server" />
<asp:UpdatePanel ID="upPanel" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnShow" runat="server" Text="Show me text later" OnClick="btnShow_Click" />
        <p id="ptext" runat="server"></p>
    </ContentTemplate>
</asp:UpdatePanel>

@弗雷德。。我正在搜索如何在asp.net..web应用程序..中实现,而不是在windows应用程序中。它被标记为asp.net。这里是另一个,因此已经有许多示例
<asp:ScriptManager ID="sm" runat="server" />
<asp:UpdatePanel ID="upPanel" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnShow" runat="server" Text="Show me text later" OnClick="btnShow_Click" />
        <p id="ptext" runat="server"></p>
    </ContentTemplate>
</asp:UpdatePanel>
protected void btnShow_Click(object sender, EventArgs e)
{
    System.Threading.Thread.Sleep(5000);
    ptext.InnerText = "5 seconds past";
}