我很接近完成我的计划,但我有一个问题。无论如何我可以暂停循环,直到播放完 Windows Media Player 中的所有文件。就像在过程中的例子:
process.WaitForExit();
while (!process.HasExited)
Thread.Sleep(500);
代码:
private bool listbox3job()
{
AxWMPLib.AxWindowsMediaPlayer axWmp =
wfh.Child as AxWMPLib.AxWindowsMediaPlayer;
DateTime? start = starttid2.Value;
DateTime? end = sluttid2.Value;
DateTime now = DateTime.Now;
if (start == null || end == null)
{
}
else if (now >= start.Value && now <= end.Value)
{
while (DateTime.Now < end.Value) // Loops till DateEndTime.
{
foreach (var selected in listBox3.Items) // Each file in ItemList.
{
string s = selected.ToString();
if (listBox3Dict.ContainsKey(s))
{
axWmp.URL = (listBox3Dict[s]); //Where all WMP files starts
}
}
}
return true;
}
return false;
}