如果 Datetime 开始,我需要帮助制作一个每秒检查一次的代码。如果它已启动,它应该关闭已经运行的功能。我知道 dispatchertimer 但我希望它在后台运行线程。原因是因为我有一个媒体播放器,它一直播放到日期时间开始,导致电影每 1 秒重新启动一次。
如果你们能帮助我,我将非常感谢,有点绝望......
Dictionary<string, string> listBox3Dict = new Dictionary<string, string>();
private bool listbox3job()
{
AxWMPLib.AxWindowsMediaPlayer axWmp =
wfh.Child as AxWMPLib.AxWindowsMediaPlayer;
DateTime? start = DateTimePicker1.Value;
DateTime? end = DateTimePicker2.Value; // This. End date. If end date. Stop movie.
DateTime now = DateTime.Now;
if (start == null || end == null)
{
}
else if (now >= start.Value && now <= end.Value)
{
foreach (var selected in listBox3.Items)
{
string s = selected.ToString();
if (listBox3Dict.ContainsKey(s))
{
axWmp.URL = (listBox3Dict[s]);
}
}
return true;
}
return false;
}