6、blic class AsyncDemo { 5.// The method to be executed asynchronously. 6.// 7.public string TestMethod( 8.int callDuration, out int threadId) { 9.Console.WriteLine("Test method begins."); 10.Thread.Sleep(callDuration); 11.threadId = AppDomain.GetCurrentThreadId(); 12.return "MyCallT
7、ime was " + callDuration.ToString(); 13.} 14.} 15. 16.// The delegate must have the same signature as the method 17.// you want to call asynchronously. 18.public delegate string AsyncDelegate( 19.int callDuration, out int threadId); 20. 21. 22.using System; 23.using System.Threadi