I have a web app that's running a bunch of data processing jobs on the backend, so rather than bogging down the server I want to schedule jobs and decided to give Quartz.Net a go.
The obvious thing to do I guess is to create the scheduler as a windows service. I have something similar running, but find a windows service is a bit of a pain for several reasons (one of them being if it crashes it needs to be manually restarted).
I was thinking that a more elegant way would be to create the service as a singleton, my questions would be:
if I have several ashx backend calls, can I just declare it like this:
public static IScheduler Scheduler { get; private set; }
in each ashx and it would be a singleton across all backend calls?
Can I check for running jobs
scheduler.GetCurrentlyExecutingJobs();
and the shut the scheduler down if there aren't any?The main reason I want to use Quartz.Net is to limit the amount of jobs running concurrently, so basically I just create simple jobs that run now. So from what I read, if there are no threads available, a job will be rejected and then handled once threads become available again. Does
scheduler.GetCurrentlyExecutingJobs();
return all rejected/waiting jobs as well?- How do I start the scheduler if it's down? It could be down because IIS closed it or because my code closed it if no jobs are running. Ideally, if I add a new job, the scheduler will start up. I guess, I could maintain my own list of jobs in an array and manage it like that - or is there a way to do it via Quartz directly? Or do I better make the scheduler permanent like this - IIS app pool recycle + quartz scheduling?