a kind of async programming in c#, need to reference definition
2024-08-30 01:12:05
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;
}
最新文章
- UIApplication详解
- php中读写excel表格文件示例。
- C 文件读写2
- 初学者对Spring MVC的认识
- Map的3种遍历[轉]
- STM32F0xx_DMA收发USART数据配置详细过程
- 一、cocos2dx概念简介
- js数据转换
- Ubuntu 不支持 rpm
- linux压缩及vi操作
- Java多线程学习之wait、notify/notifyAll 详解
- mysql5.6 绿色免安装版 安装详解
- 背包DP入门小笔记01背包
- JMeter Concurrency Thread Group阶梯式加压
- zookeeper(zkCli)命令概览
- C语言memcpy函数的用法
- C#语法——事件,逐渐边缘化的大哥。
- vue组件之间的通信
- mongodb shell 运行js脚本的四种方式
- bzoj 1002