c# System.Threading.Timer是多线程,并能同时执行

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiuzhentianting/article/details/48264029
public static void RunTimerTimer(object Sender)
{
Console.WriteLine(String.Format("BeginSleep ID:{0} Tick:{1}", Thread.CurrentThread.ManagedThreadId, HUtil32.GetTickCount()));
Thread.Sleep(200);
Console.WriteLine(String.Format("EndSleep ID:{0} Tick:{1}", Thread.CurrentThread.ManagedThreadId, HUtil32.GetTickCount()));
}

unsafe static void Main(string[] args)
{


System.Threading.Timer RunTimer = new System.Threading.Timer(new TimerCallback(RunTimerTimer), null, 0, 100);





Console.ReadKey();
}

会出现:
多个Begin然后End
展开阅读全文

没有更多推荐了,返回首页