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. Mysql的一些纪要

    unsigned 整型的每一种都分无符号(unsigned)和有符号(signed)两种类型(float和double总是带符号的),在默认情况下声明的整型变量都是有符号的类型(char有点特别),如 ...

  2. java抓取12306火车余票信息

    最近在弄一个微信的公众帐号,涉及到火车票查询,之前用的网上找到的一个接口,但只能查到火车时刻表,12306又没有提供专门的查票的接口.今天突然想起自己直接去12306上查询,抓取查询返回的数据包,这样 ...

  3. ATM-core-src

    from interface import bank, shopping, userfrom lib import common user_data = { 'name': None} def log ...

  4. .net core 获取浏览器UserAgent

    这两天由于自己公司的机器磁盘不够用了,果断把VS2015卸载了,只留下VS2017 当我打开一个以前一个很简单的MVC4.0的项目时候 温馨提示要安装MVC4,我犹豫了一下,还是点了安装,接下来提示要 ...

  5. tcl之内容

  6. wusir 面试题答案在老男孩的视频里

    注意:你问答案在哪里?答案在视频里了,就是不给你写. 第一部分 Python基础篇(80题) 为什么学习Python? 通过什么途径学习的Python? Python和Java.PHP.C.C#.C+ ...

  7. UVA - 753 A Plug for UNIX(网络流)

    题意 给定一些插头设备和插座,有一些方法可以把其中一些插头变成另一种插头.求无法匹配插座的插头设备个数. 题解 用\(map\)给每个字符串标号为\(a_i\)和\(b_i\). 读入每种改变插头的方 ...

  8. loj2173 「FJOI2016」建筑师

    ref 真是道组合数学神题啊--第一次见第一类斯特林数-- #include <iostream> #include <cstdio> using namespace std; ...

  9. loj2042 「CQOI2016」不同的最小割

    分治+最小割 看到题解的第一句话是这个就秒懂了,然后乱七八糟的错误.越界.RE-- #include <algorithm> #include <iostream> #incl ...

  10. Linux服务器管理员必备Linux命令TOP5

    Linux桌面环境的界面友好度.图形性能及附件工具已经大幅进化,然而Linux服务器却还没有能达到这一步. 作为系统管理员必须熟练掌握Linux命令.Linux命令的内容很多,其中的一些TOP命令对于 ...