Sleep a server thread : Thread « Development « ASP.NET Tutorial






<%@ Page %>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  int i;
  System.Threading.Thread myThread;
  System.Threading.ThreadStart myThreadStart;

  myThreadStart=new System.Threading.ThreadStart(DoSomething);
  myThread=new System.Threading.Thread(myThreadStart);
  myThread.Start();
  for (i=1;i<6;i++)
  {
    System.Threading.Thread.Sleep(100);
    myLabel.Text+=i + "<BR>";
  }
  myThread.Abort();
}

private void DoSomething()
{
  int i;
  for (i=11;i<21;i++)
  {
    System.Threading.Thread.Sleep(100);
    myLabel.Text+=i + "<BR>";
  }
}
</script>
<HTML>
  <body>
    <form id="form1" method="post" runat="server">
    <asp:Label ID="myLabel" Runat="server"></asp:Label>
    </form>
  </body>
</HTML>








9.43.Thread
9.43.1.TracingOutput.aspx
9.43.2.Start a thread
9.43.3.Sleep a server thread