1:是的,Thread.Sleep(毫秒); 1秒 == 1000毫秒
2:在死循环外层的代码当然没法访问。
文件存在跳出循环,结束线程可以这样写:
while (true) {
if (System.IO.File.Exists("path")) {
return;
}
System.Threading.Thread.Sleep(15000);
}
2:在死循环外层的代码当然没法访问。
文件存在跳出循环,结束线程可以这样写:
while (true) {
if (System.IO.File.Exists("path")) {
return;
}
System.Threading.Thread.Sleep(15000);
}
2.你sleep写死循环外面了,当然得不到执行.起码得有跳出循环的代码啊.
使用break可以跳出循环,或者不要while(true),而是while(bool),在执行过程中改变bool值,循环就结束了
否则while后面还有其他代码,就得不到执行了.