2

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

pickypg
  • 22,034
  • 5
  • 72
  • 84
Gullu
  • 3,477
  • 7
  • 43
  • 70

1 Answers1

2

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

Community
  • 1
  • 1
Bongo Sharp
  • 9,450
  • 8
  • 25
  • 35
  • thx. I played with quartz.net and could not get it to work out of box. There are many samples for complex scenarios but nothing simple like say open notepad 10 secs from now. If you find any such articles please post. If there is nothing commercial I will dig deeper into quartz.net. – Gullu May 12 '11 at 19:04
  • Where did you got stuck using Quartz.net? maybe i can help you out – Bongo Sharp May 12 '11 at 20:23
  • Please point me to any small online sample that does something like what is shown on the main page of http://taskscheduler.codeplex.com/. thx – Gullu May 12 '11 at 20:32
  • awesome Bongo. Thx. I will try that code out. I scoured the web but could not find any commercial .net scheduling components (non gui). Most of the available ones have an outlook like gui for appointment calendar scheduling. I guess I have no choice but to go with either quartz or the codeplex task scheduler. – Gullu May 13 '11 at 13:06
  • @Gullu: I hope you have found a way forward, but for the benefit of the community, I have used Quartz.NET in a WinNT service with excellent results. My triggers as as varied as Once Daily, Couple of times in the day to ones that get fired every 10 minutes. Following is the basic pattern I have followed to achieve this: 1. Fetch jobs and their scheduling information from database 2. iterate over the collection of Jobs 3. For each job, build an ITrigger using the cron schedule builder 4. Scheduler jobs – Sudhanshu Mishra Dec 12 '12 at 05:53