using System;
using System.Threading ;
namespace AsyncDemo
{
/**//// <summary>
/// 如何異步調用 Visual C# 方法
/// 出自:http://support.microsoft.com/default.ASPx?scid=kb%3Bzh-cn%3B315582
/// </summary>
class AsyncDemo
{
/**//// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main(string[] args)
{
AsyncDemo ad = new AsyncDemo () ;
ad.DemoSyncCall() ;
//ad.DemoEndInvoke();
//ad.DemoWaitHandle();
//ad.DemoPolling();
//ad.DemoCallback();
Console.Read();
}
string LongRunningMethod (int iCallTime, out int IExecThread)
{
Console.WriteLine("write now...");
Thread.Sleep (iCallTime) ;
IExecThread = AppDomain.GetCurrentThreadId ();
return "MyCallTime was " + iCallTime.ToString() ;
}
delegate string MethodDelegate(int iCallTime, out int IExecThread) ;
&nbs