




















看企业库的ConfigurationChangeWatcher,里面用了多线程,自己以前没有写过,写了一个小demo,最简单的,分享一下:
[STAThread]
static void Main(string[] args)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(test));
t.Start();
System.Threading.Thread.Sleep(500);
for (int i = 0 ; i < 1000 ; i++)
{
Console.WriteLine("main");
System.Threading.Thread.Sleep(1000);
}
}
static void test()
{
for (int i = 0 ; i < 1000 ; i++)
{
Console.WriteLine("test");
System.Threading.Thread.Sleep(1000);
}
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。