Skip to content

Commit 1618b06

Browse files
committed
Reorder StartNow block in AddTrigger method
Moved the conditional block that checks `jobTriggerAttribute.StartNow` and calls `opts.StartNow()` to after the job's schedule setup with `opts.ForJob(jobKey)`. This ensures the job's schedule is fully configured before deciding to start the job immediately.
1 parent c0d1a85 commit 1618b06

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/EasyExtensions.Quartz/Extensions/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ private static void SetupQuartz(IServiceCollectionQuartzConfigurator configurato
5656
.DisallowConcurrentExecution());
5757
configurator.AddTrigger(opts =>
5858
{
59-
if (jobTriggerAttribute.StartNow)
60-
{
61-
opts.StartNow();
62-
}
6359
opts.ForJob(jobKey)
6460
.WithIdentity(job.Name + "Trigger")
6561
.WithSimpleSchedule(x =>
@@ -71,6 +67,10 @@ private static void SetupQuartz(IServiceCollectionQuartzConfigurator configurato
7167
x.RepeatForever();
7268
}
7369
});
70+
if (jobTriggerAttribute.StartNow)
71+
{
72+
opts.StartNow();
73+
}
7474
jobAdded?.Invoke(job);
7575
});
7676
}

0 commit comments

Comments
 (0)