timer的话就不是这么写了,而是先建一个timer
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(theout);
aTimer.Interval = 1000;
aTimer.AutoReset = true;
aTimer.Enabled = true;
然后在theout()里写你要定时执行的内容,如
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
if (DateTime.Now.Minute % 10 == 9 && DateTime.Now.Second == 30)
//if (DateTime.Now.Second == 50)
{
if (isNeedNotify)
{
new WFTesting().ShowDialog();
}
}
}
先timer.enabled=false,执行需要延迟的地方后再=true
不清楚你程序的机制不太好说,你那个timer具体是做什么用的,如果是计时的,并且你是在timer中做了累加,建议改成计算时间的差值,这样二者就不会干扰。
使用Thread.Timer即可满足你的需求!
Task.Delay()
网页链接