C# Running several tasks at different intervals
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 minutesI 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.
精彩评论