Question

I am aware of quartz.net and the codeplex task scheduler managed wrapper project. They have a rather decent learning curve and R&D phase to get it to work as per our specs. Also packaging them & configuring with our runtime installer is another issue. So we have decided to go with a commercial .NET task scheduler.

Our requirements are:

  1. Must be supported on Win xp and Win 7 (x86 + x64)
  2. Must provide a callback or event when trigger is fired.

Sample psuedo code:

Trigger mytrigger = new Trigger(Daily, "8:00am", myCallbackDelegate);
mytrigger.Start();

Every day at 8:00 method pointed to by myCallbackDelegate will be called.

The scheduler can run as service or everytime the app that references it is started. .NET component that can be dropped on the form and configured preferred.

Please provide your recommendations. I have googled and cannot find anything that will do this basic functionality. thanks

Was it helpful?

Solution

I have used Quartz.Net in a WCF Service and it has worked really good, it has lots of flexibility due to the Cron Triggers, basically you can work out most of the scenarios of scheduling, when you schedule a trigger, you need to specify a type of a class that implements the IJob Interface. In my case the Execute methods calls a singleton class/method to do the job it needs to perform. You can configure the Triggers to be stored on RAM (volatile) or a Database, i think you can specify a custom storage but i haven't go that way.

The only problem that i had with Quartz.NET is described in this question, I also posted the solution that i worked out, if you have more specific questions please let me know.

This is some of the configuration basics of Quartz.NET mosthly followed from the Tutorial

For instantiating the Scheduler you do something like this:

ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
_scheduler = schedulerFactory.GetScheduler();
_scheduler.Start()

For scheduling a job you will do something like this

JobDetail jobDetail = new JobDetail("UNIQUE NAME", null, typeof(NotepadJob));
SimpleTrigger triggerToReturn = new SimpleTrigger();
triggerToReturn.StartTimeUtc = DateTime.Now.ToUniversalTime();
_scheduler.ScheduleJob(jobDetail,trigger);

and the Job will be something like this

internal class NotepadJob : IJob
{
    //Open Notepad
}

If wokring with SQL you can configure the settings as followed on the Config file:

  <configSections>
      <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  <\configSections>


<quartz>
  <add key="quartz.scheduler.instanceName" value="DefaultQuartzJobScheduler" />
  <add key="quartz.scheduler.instanceId" value="AUTO" />
  <add key="quartz.jobstore.clustered" value="true" />
  <add key="quartz.jobstore.clusterCheckinInterval" value="15000" />
  <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
  <add key="quartz.jobStore.useProperties" value="false" />
  <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
  <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
  <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
  <add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
  <add key="quartz.jobStore.misfireThreshold" value="60000" />
  <add key="quartz.jobStore.dataSource" value="default" />
  <add key="quartz.dataSource.default.connectionString" value="[CONNECTION STRING]" />
  <add key="quartz.dataSource.default.provider" value="SqlServer-20" />
  <add key="quartz.threadPool.threadCount" value="10" />
</quartz>

-Regards

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top