首页 > Windows开发 > 详细

a kind of async programming in c#, need to reference definition

时间:2015-10-31 20:02:04      阅读:279      评论:0      收藏:0      [点我收藏+]

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

  

 

a kind of async programming in c#, need to reference definition

原文:http://www.cnblogs.com/hualiu0/p/4925936.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!