我对 C# 很陌生,我正在使用修改后的 WPF 应用程序。我的程序的问题是循环是无限的......而(现在<结束)并没有在结束时间结束它仍然继续直到你终止主进程。该程序正在显示电影和图片,因此每次都不同。这意味着 now = now.AddSeconds 不起作用。对?
启动信息 = 列表框
private bool startjob() //DateTime checking for DateValue and start's if correct value.
{
DateTime? start = DateTimePicker1.Value;
DateTime? end = DateTimePicker2.Value;
DateTime now = DateTime.Now;
if (start == null || end == null)
{
Xceed.Wpf.Toolkit.MessageBox.Show("one of the pickers is empty");
}
else if (now >= start.Value && now <= end.Value)
{
while (now < end)
{
foreach (var selected in startupinfo.SelectedItems)
{
string s = selected.ToString();
if (startupinfoDict.ContainsKey(s))
{
Process process = Process.Start(startupinfoDict[s]);
process.WaitForExit();
while (!process.HasExited)
Thread.Sleep(500);
}
}
foreach (var selected in listBox2.SelectedItems)
{
string s = selected.ToString();
if (listBox2Dict.ContainsKey(s))
{
Process process = Process.Start(listBox2Dict[s]);
process.WaitForExit();
while (!process.HasExited)
Thread.Sleep(500);
}
}
}
return true;
}
return false;
}