我正在尝试跳出一个while循环。基本上,如果满足“if”条件,我希望能够退出这个循环:
我试图跳出while循环。如果满足"if"条件,我想要能够退出该循环:
private void CheckLog()
{
while (true)
{
Thread.Sleep(5000);
if (!System.IO.File.Exists("Command.bat"))
continue;
using (System.IO.StreamReader sr = System.IO.File.OpenText("Command.bat"))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
if (s.Contains("mp4:production/CATCHUP/"))
{
RemoveEXELog();
Process p = new Process();
p.StartInfo.WorkingDirectory = "dump";
p.StartInfo.FileName = "test.exe";
p.StartInfo.Arguments = s;
p.Start();
<< Escape here - if the "if" condition is met, escape the loop here >>
}
}
}
}
}
break;
不起作用了吗? - Jongoto
的少数情况之一。 - Yakimychbreak
。goto
的问题/优势在于它太不受限制了。 - user166390