zoukankan      html  css  js  c++  java
  • asp.net WebService异步

     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
  • 相关阅读:
    MySQL length函数
    MySQL between ... and ...
    MySQL Group By使用
    MySQL 聚合函数/分组函数
    MySQL where与like
    MySQL order by与distinct
    城市网络
    滑动窗口
    合并回文子串(NC13230)
    NC50439
  • 原文地址:https://www.cnblogs.com/jiebo/p/4281813.html
Copyright © 2011-2022 走看看