a kind of async programming in c#, need to reference definition
2015-10-31 18:26
369 查看
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; }
相关文章推荐
- jquery $(document).ready() 与window.onload的区别
- 200多个js技巧代码
- 真正的中国天气api接口xml,json(求加精) ...
- 运行ReactNative示例
- html中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
- ReactNative项目配置要点
- 已有Android工程集成ReactNative页面
- BootStrap中datepicker的使用和修改
- JavaScript之模块化编程
- sublime3快捷 输入html
- jquery刷新页面
- 关于IE浏览器加载外部js注意事项
- jQuery笔记
- jQuery插件开发小记
- node.js+express验证码的实现
- node.js定时任务:node-schedule的使用
- 前端和后端的输入合法性验证
- [LeetCode][JavaScript]Bulls and Cows
- jsp页面跳转
- 用getAttribute获取控制层获取的数据,显示在jsp页面