开发者

Scheduled task with windows services and system.timer.timer

i want implement a windows services scheduled task. I already created windows service. In开发者_运维百科 a service i have implemented a timer.The timer is initialized at class interval. The timers interval is set in the start method of service and also it is enabled in the start method of the service. After timers elapsed event is fire i have done some actions.

My problem is that, i am in a dilemma. Lets say the action i have done in Elapsed event, lets say take one hour and the timers interval is set to half an hour. so there are chances that even if the previous call to elapsed event has not ended new call to elapsed event will occur.

my question will there be any conflict or is it ok or shall i use threads. please give some advice


You can stop the timer at the begining of your long running method, then start it again at the end:

Timer.Change(Timeout.Infinite, Timeout.Infinite)
// do long task ...
Timer.Change(dueTime,period)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜