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. 删除Zend Studio项目

    导入了过大的项目,导致很卡,且Close Project和Delete操作不了,一直无响应. 调整项目目录下的隐藏文件夹,删除对应项目: E:\www\.metadata\.plugins\org.e ...

  2. Python全栈学习:匿名函数使用规范

    匿名函数,当我们在传入函数时,有些时候,不需要显式地定义函数,直接传入匿名函数更方便. 在Python中,对匿名函数提供了有限支持.还是以map()函数为例,计算f(x)=x2时,除了定义一个f(x) ...

  3. python模块之collections模块

    计数器 Counter 计数元素迭代器 elements() 计数对象拷贝 copy() 计数对象清空 clear() from collections import Counter #import ...

  4. Hive UDF开发指南

    编写Apache Hive用户自定义函数(UDF)有两个不同的接口,一个非常简单,另一个...就相对复杂点. 如果你的函数读和返回都是基础数据类型(Hadoop&Hive 基本writable ...

  5. 重写BaseAdapter实现ListView

    public class BaseAdapterActivity extends BaseActivity { private ListView base_adapter_listView; priv ...

  6. 自己用C语言写RH850 F1KM serial bootloader

    了解更多关于bootloader 的C语言实现,请加我QQ: 1273623966 (验证信息请填 bootloader),欢迎咨询或定制bootloader(在线升级程序). 手上有块Renesas ...

  7. Jetty,Tomcat对MIME协议的配置参数说明

      此处做一下小的汇总,针对Jetty容器内,存在excel的xlsx文件直接通过链接的方式下载的时候,如果是在Chrome浏览器时,则直接触发浏览器的下载行为,但是在IE11的浏览器上,则浏览器会直 ...

  8. Selenium Java 自动化 介绍及开发工具的使用(一)

    前言 目前selenium版本已经升级到3.0了,网上的大部分教程是基于2.0写的,所以在学习前先要弄清楚版本号,这点非常重要.本系列依然以selenium2为基础,目前selenium3本人没做过研 ...

  9. MongoDB01——安装MangoDB

    一.MongoDB的下载 到MongoDB的官网——https://www.mongodb.com/download-center/community,选择要下载的版本,点击Download 二.安装 ...

  10. Selenium - WebDriver: Waits

    These days most of the web apps are using AJAX techniques. When a page is loaded to browser, the ele ...