首页 > Web开发 > 详细

asp.net WebService异步

时间:2015-02-09 17:57:04      阅读:301      评论:0      收藏:0      [点我收藏+]
 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

 

asp.net WebService异步

原文:http://www.cnblogs.com/jiebo/p/4281813.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!