日期:2014-05-18  浏览次数:20401 次

windows服务问题 急等...
#region 时钟调度
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{

this.timer1.Enabled = false;
try
{

//////提醒
MissionReport_VacationApply_TX();//提醒
}
catch(Exception ex)
{
string xun = ex.ToString();
}
this.timer1.Enabled = true;
}
#endregion

代码如上 ,我怎么样判断 服务运行时,每一天下午 17:00 走( MissionReport_VacationApply_TX() 方法)  
并且只 走 一次???

------解决方案--------------------
在Timer_Tick中你判断DateTime.Now.Hours==17:00
------解决方案--------------------
走一次?
int times=1;
private void timer1_Tick(object sender, EventArgs e)
{
if(times<=0)
{
timer1.Stop();

return;
}
times--;
}