asp.NetWebService非同期

1276 ワード

 1 #region       
 2         //  
 3         public delegate void PrintDelegate(string s);
 4         [WebMethod]
 5         public string yibu() 
 6         {
 7             //       
 8             PrintDelegate printDelegate = Print;
 9             printDelegate.BeginInvoke("", PrintComeplete, printDelegate);
10             return "OK";
11         }
12 
13         public static void Print(string s)
14         {
15             //"        "     
16             Service svice2 = new Service();
17             for (int i = 0; i < 999999999; i++)
18             {
19                svice2.TestTabAdd(i.ToString());
20             }
21             Thread.Sleep(5000);
22         }
23         //      
24         //1.     void
25         //2.      IAsyncResult
26         public static void PrintComeplete(IAsyncResult result)
27         {
28             (result.AsyncState as PrintDelegate).EndInvoke(result);
29             //Console.WriteLine("      ." + result.AsyncState.ToString());
30         }
31         #endregion