I have used cron schedule in C# to create an application that should trigger a job only once. This code piece is throwing an exception, An unhandled exception of type 'Quartz.SchedulerException' occurred in Quartz.dll
Below is my code:
class Program
{
static void Main(string[] args)
{
Test();
}
public static void Test()
{
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
IScheduler scheduler = schedulerFactory.GetScheduler();
IJobDetail jobDetail = JobBuilder.Create<SatellitePaymentGenerationJob>()
.WithIdentity("TestJob")
.Build();
Console.WriteLine(DateBuilder.DateOf(16, 30, 00, 24, 2, 2015));
//ITrigger trigger = TriggerBuilder.Create()
// .ForJob(jobDetail)
// .WithCronSchedule("0 0 12 20 4 ? *")
// .WithIdentity("TestTrigger")
// .StartNow()
// .Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDescription("Once")
.WithSimpleSchedule(x => x.RepeatForever().WithRepeatCount(1))
.StartAt(DateBuilder.DateOf(12, 43, 00, 26, 2, 2015))
.Build();
scheduler.ScheduleJob(jobDetail, trigger);
scheduler.Start();
}
}
internal class SatellitePaymentGenerationJob : IJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("test");
}
}
I believe that the way I have done scheduling to be execute only once is causing the issue. Please advice.
mayooran99
No comments:
Post a Comment