4

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.

Thierry
  • 6,142
  • 13
  • 66
  • 117

1 Answers1

2

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.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • Hi Anton, thanks for the feedback, but now that I've simplified my question as it was too broad, I feel, it's not explaining correctly what my actual question is. My issue is not with the scheduler. I've designed on in the past and as you said, it was trivial at all. My concern is how best approach the threading regarding scheduled jobs and permanently running jobs. Would using the threadpool for scheduled jobs be ok while storing the permanently running jobs in background threads or is there a better way to do this? Sorry for the confusion if any. – Thierry Oct 03 '16 at 13:53