using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading ; namespace 多线程 { class Program { public delegate int TakesAwhileDel ( int data , int ms ) ; static void Main(string[] args) { //异步委托 TakesAwhileDel dl = TakesAwhile ; IAsyncResult re = dl.BeginInvoke( 1 , 3000 , null , null ) ; while( !re.IsCompleted ) { Console.WriteLine( "等" ) ; Thread.Sleep( 50 ) ; } int result = dl.EndInvoke( re ) ; Console.WriteLine( "最后结果{0}" , result.ToString() ) ; Console.ReadLine() ; } static int TakesAwhile( int data , int ms ) { Console.WriteLine( "开始调用" ) ; Thread.Sleep( ms ) ; Console.WriteLine( "完成调用" ) ; return ++ data ; } } }