Thierry
Thierry

Reputation: 6458

Best design for permanently and scheduled tasks

I have requirement where I need to have some tasks to run permanently while some other should just be run on a scheduled basis but I'm not sure what the best way to handle this scenario should be.

For the scheduled jobs, I thought I'd use a Thread Pool and for jobs running permanently, I thought I'd just have an array of threads that would be created and started as my Windows Service starts.

Is that a correct and/or best approach or is there a better way to handle this?

Note that I need to be able to cancel a running job whether it be scheduled and/or permanently running.

Thanks

PS: Please note this question has been totally re-phrased as it was originally too broad. I hope this is a better attempt at it.

UPDATE:

Please note this question is not about a scheduler issue but more on what is the best approach to handle my threads based on my 2 requirements i.e. scheduled vs continuous.

Sorry for any confusion.

Upvotes: 4

Views: 240

Answers (1)

Anton Gogolev
Anton Gogolev

Reputation: 115741

Writing your own scheduler is not as trivial as it may seem to be. With that in mind, there are only two reliable options: use Quartz.NET (which is what I personally recommend) or use Windows Scheduler.

Quartz.NET has somewhat of a learning curve (not very steep, though), and Windows Scheduler (if interfaced with using TSMW) has, to my taste, a very cumbersome API.

Upvotes: 2

Related Questions