0

I'm using Quartz.NET 3 as a job scheduler in my application

Sometimes, I need to schedule a job for a "one time" immediate execution. At the moment I'm doing it like this:

//Create job
var uid = Guid.NewGuid().ToString();
IJobDetail jobDetail = JobBuilder.Create<MyJobClass>()
    .WithIdentity(uid, "ImmediateJobs")
    .Build();

//Create instant-activation trigger
ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger-" + uid, "ImmediateJobsTriggers")
    .StartNow()
    .Build();

//Schedule job for execution
scheduler.ScheduleJob(jobDetail, trigger);

My question is this: is this enough or does this cause possibile memory leaks? Should I somehow remove the job when finished or do any other cleanup operations? Or is it done automatically, since the job doesn't have any other triggers?

Master_T
  • 7,232
  • 11
  • 72
  • 144

1 Answers1

0

After reading further the documentation, I found out you can trigger an existing job by using:

var jobKey = new JobKey(id, group);
scheduler.TriggerJob(jobKey);

without creating a new one each time.

Master_T
  • 7,232
  • 11
  • 72
  • 144