一个windows服务,能不能在OnStart事件中启动两个线程,这样写可以吗? protected override void OnStart(string[] args)
{
// TODO: 在此处添加代码以启动服务。
Thread trcheck = new Thread(new ThreadStart(Check));
trcheck.Start();
Thread trcheck2 = new Thread(new ThreadStart(Check2));
trcheck2.Start();
}
private void Check()
{
while (true)
{
....
}
}
private void Check2()
{
while (true)
{
....
}
}
{
// TODO: 在此处添加代码以启动服务。
Thread trcheck = new Thread(new ThreadStart(Check));
trcheck.Start();
Thread trcheck2 = new Thread(new ThreadStart(Check2));
trcheck2.Start();
}
private void Check()
{
while (true)
{
....
}
}
private void Check2()
{
while (true)
{
....
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货