zoukankan      html  css  js  c++  java
  • a kind of async programming in c#, need to reference definition

    
    
    void Main()
    {
    	Run d=new Run(RunHandler);
    	IAsyncResult result= d.BeginInvoke(new AsyncCallback(CallBack),new string[]{"sdf","sdffd"});
    	IAsyncResult res=d.BeginInvoke(r=>{},"");
    	//i.e. asyncresult is a wrapperclass that wraps the state
    	d.EndInvoke(d.BeginInvoke(re=>{Console.WriteLine (re.AsyncState);},"async state"));
    	d.EndInvoke(result);
    	Console.WriteLine (3);
    }
    void RunHandler(){
    Console.WriteLine (1);
    }
    void CallBack(IAsyncResult result){
    Console.WriteLine (result.AsyncState);
    Console.WriteLine (2);}
    
    // Define other methods and classes here
    public delegate void Run();
    
    
    

      

    
    

    result showed like:

    1
    1
    
    5String[] (2 items)4 
    sdf 
    sdffd 
    
    2
    1
    3
    

      

    void Main()
    {
    	Console.WriteLine (Geta().Result);
    }
    
    // Define other methods and classes here
     async Task<String> Get(){
    return "aa";
    }
    async Task<string> Geta(){
    var a=await Get();
    return "bb"+a;
    }
    

      

  • 相关阅读:
    雑談
    safari下无法模拟click()的解决方法 ------转载
    用户操作
    居中
    replace 重写
    JS数组添加元素的三种方式
    Asp.Net Core 包
    CSS3 动画 可以参考
    CSS3 动画
    完全居中
  • 原文地址:https://www.cnblogs.com/hualiu0/p/4925936.html
Copyright © 2011-2022 走看看