⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asynccall.cs

📁 asp.net经典案例资料
💻 CS
字号:
using System;

public class WebServiceApp
{
  public static string Result = "";
  public static void Main()
  {
    Console.WriteLine("Starting to call Web Service...");

    HelloMore hm = new HelloMore();
    AsyncCallback cb 
      = new AsyncCallback(WebServiceApp.SayHelloMoreCallback);
    IAsyncResult ar = hm.BeginSayHelloMore("Async", cb, hm);

    int start = DateTime.Now.Second;
    int currentSecond = start;
    while (ar.IsCompleted == false)
    {
      if (currentSecond < DateTime.Now.Second)
      {
         currentSecond = DateTime.Now.Second;
         Console.WriteLine("Seconds Elapsed..." + (currentSecond - start).ToString() );
      }
    }

    Console.WriteLine(Result);
    Console.WriteLine("Finishing Web Service Call");
    return;
  }

  public static void SayHelloMoreCallback(IAsyncResult ar)
  {
    HelloMore hm = (HelloMore) ar.AsyncState;
    Result = hm.EndSayHelloMore(ar);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -