I am using Quartz.Net to schedule task. I have tried like wise.
Started a visual studio console application and added two reference i.e Quartz.dll and Common.Logging.dll along with System.Web.Services;
Then i coded a little bit for a normal task as provided on the link http://simplequartzschedulerincsharp.blogspot.com/ (They are claiming that its working)
But as soon as i tried to Run the program it gave error as "Missing reference to Quartz.all" but i have added this already.
Why this is happening ?
Also somewhere i noted that one need to install the Quartz.Server.Service to use it etc. etc.
Please guide me and please dictate me a simple but working example and points i am missing ?
The example on the site is probably outdated.
I made some modifications to the classes used and now it runs:
using System;
using Quartz;
using Quartz.Impl;
using Quartz.Impl.Triggers;
// Necessary references:
// Quartz dll
// Common.Logging
// System.Web
// System.Web.Services
namespace QuartzExample
{
class Program
{
private static IScheduler _scheduler;
static void Main(string[] args)
{
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
_scheduler = schedulerFactory.GetScheduler();
_scheduler.Start();
Console.WriteLine("Starting Scheduler");
AddJob();
}
public static void AddJob()
{
IMyJob myJob = new MyJob(); //This Constructor needs to be parameterless
JobDetailImpl jobDetail = new JobDetailImpl("Job1", "Group1", myJob.GetType());
CronTriggerImpl trigger = new CronTriggerImpl("Trigger1", "Group1", "0 * 8-17 * * ?"); //run every minute between the hours of 8am and 5pm
_scheduler.ScheduleJob(jobDetail, trigger);
DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
Console.WriteLine("Next Fire Time:" + nextFireTime.Value);
}
}
internal class MyJob : IMyJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("In MyJob class");
DoMoreWork();
}
public void DoMoreWork()
{
Console.WriteLine("Do More Work");
}
}
internal interface IMyJob : IJob
{
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With