예제 #1
0
        /// <summary>
        /// 求结果
        /// </summary>
        /// <param name="ar"></param>
        /// <returns></returns>
        public string EndRun(IAsyncResult ar)
        {
            if (ar == null)
            {
                throw new NullReferenceException("Arggument ar can't be null");
            }

            Console.WriteLine("【2】EndRun excuting");

            return(_runDelegate.EndInvoke(ar));
        }
예제 #2
0
  public static void Main(){
		RunDelegate runDelegate1 = new RunDelegate(Run);
		RunDelegate runDelegate2 = new RunDelegate(Run);
		IAsyncResult result1 = runDelegate1.BeginInvoke("Hello", null, null);
		IAsyncResult result2 = runDelegate2.BeginInvoke("World!", null, null);
		while(!(result1.IsCompleted && result2.IsCompleted)){
			Console.Write(" - ");
			Thread.Sleep(1000);
		}
		runDelegate1.EndInvoke(result1);
		runDelegate2.EndInvoke(result2);
		Console.WriteLine("\nMain thread exiting now...bye!");
  } // end Main() method