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;
}

  

a kind of async programming in c#, need to reference definition的更多相关文章

  1. Async Programming All in One

    Async Programming All in One Async & Await Frontend (async () => { const url = "https:// ...

  2. Async Programming - 1 async-await 糖的本质(2)

    上一篇讲了这么多,其实说的就是一个事,return会被编译器重写成SetResult,所以如果我们的异步函数返回的是一个Task<int>,代码就要改成这样: using System; ...

  3. Async Programming - 1 async-await 糖的本质(1)

    这一个系列的文章主要来讲 C# 中的语言特性 async-await 在语言层面的本质,我们都知道 await 是编译器进行了一个 rewrite,然而这个 rewrite 并不是直接 rewrite ...

  4. Async programming

    Asynchrony, in computer programming, refers to the occurrence of events independent of the mainprogr ...

  5. utilize HttpClient to generate a SSL access and generate REST access to fetch data, async programming? cool and brief

    WebRequestHandler handler = new WebRequestHandler(); try { X509Certificate2 certificate = new X509Ce ...

  6. 编程概念--使用async和await的异步编程

    Asynchronous Programming with Async and Await You can avoid performance bottlenecks and enhance the ...

  7. Async callback to awaitable Task<> z

    http://blog.tedd.no/2013/09/13/async-callback-to-awaitable-task/ The Async-Await feature in .Net is ...

  8. Parallel Programming AND Asynchronous Programming

    https://blogs.oracle.com/dave/ Java Memory Model...and the pragmatics of itAleksey Shipilevaleksey.s ...

  9. JavaScript 如何工作的: 事件循环和异步编程的崛起 + 5 个关于如何使用 async/await 编写更好的技巧

    原文地址:How JavaScript works: Event loop and the rise of Async programming + 5 ways to better coding wi ...

随机推荐

  1. Linux产生随机数的几种方法

    .echo $RANDOM .openssl rand -base64 .date +%n%N .head /dev/urandom |cksum .cat /proc/sys/kernel/rand ...

  2. PHP 批量操作 Excel

    自己封装了一个批量操作excel文件的方法,通过xls文件地址集合遍历,第三个参数传入一个匿名函数用于每个需求的不同进行的操作,实例中我想要得到列表中含有折字的行,封装成sql语句返回. xls文件超 ...

  3. 传送流(TS)的基础知识

    数字电视的TS包和TS流的组成和功能 综合考虑几下几个因素: (1)包的长度不能过短,否则包头开销所占比例过大, 导致传输效率下降 (2)包的长度不能过长,否则在丢失同步的情况下恢复同步的 周期过长, ...

  4. 动态规划:HDU-2955-0-1背包问题:Robberies

    解题心得: 这题涉及概率问题,所以要运用概率的知识进行解答.题目要求不被抓到的概率,但是给出的是被抓到的概率,所要用1减去后得到答案.最好使用double类型,避免精度问题导致WA. 先算出可以抢劫的 ...

  5. CyclicBarrier源码分析

    CyclicBarrier是通过ReentrantLock(独占锁)和Condition来实现的.下面,我们分析CyclicBarrier中3个核心函数: 构造函数, await()作出分析. 1. ...

  6. 连续小波变换CWT(2)

    如果让你说说连续小波变换最大的特点是什么?多分辨分析肯定是标准答案.所谓多分辨分析即是指小波在不同频率段会有不同的分辨率.具体表现形式,我们回到前一篇文章的第一个图, 图一 对应的信号为 低频时(频率 ...

  7. Django Rest Framework threoy

    rest_framework源码分析: 1.as_view() 2.父类的as_view() view = super(APIView, cls).as_view(**initkwargs) 3.vi ...

  8. Understanding on 'Error to Origin (50x)' , 'Internal CDN Error (50x)' and 'External Error (50x)' in Chartron

    Overview This document explains about definition of these values on OUI Chartron. Definition of Erro ...

  9. ios开发学习笔记040-autolayout 第三方框架Masonry

    不管是是界面创建约束还是代码创建约束,苹果官方提供的方式都比较繁琐.所以出现了第三方框架. Masonry 在github地址如下: https://github.com/SnapKit/Masonr ...

  10. Leetcode 647.回文子串

    回文子串 给定一个字符串,你的任务是计算这个字符串中有多少个回文子串. 具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被计为是不同的子串. 示例 1: 输入: "abc&qu ...