开发者

C# Running several tasks at different intervals

开发者 https://www.devze.com 2022-12-25 02:41 出处:网络
A design question: I\'d like to build a Windows service that executes different commands at different intervals. For simplicity\'s sake, let\'s say I want to run some batch files.

A design question:

I'd like to build a Windows service that executes different commands at different intervals. For simplicity's sake, let's say I want to run some batch files.

The input it gets is a list of files and the intervals at which to execute.

For example:

a.bat - 4 minutes

b.bat - 1 minute

c.bat - 1 minute

d.bat - 2 minutes

I was thinking 开发者_Go百科about sorting them according to intervals, and then setting a timer for each of the intervals. I'm not sure this is the best solution and I'd be happy to hear some feedbacks.

Thanks!


You can use Quartz.NET library to schedule different tasks.


I have a Windows service that does something similar (generating reports at specified times). I solved this using Quartz.NET.


Not all problems are nails that should be solved with the C# hammer. Use the Microsoft Scheduled Tasks.


Well since you're using C#, why not create threads instead of using timers? Then set the thread for a batch file to sleep or run at different intervals.

0

精彩评论

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

关注公众号