Open skarum opened 2 hours ago
Hey @skarum
No that is absolutely not intentional (at least until now :D) and should be fixed! Thanks for the report!
Ohh - can see I forgot to link to the commit: https://github.com/NCronJob-Dev/NCronJob/commit/0fe7e6666d074b2c83ce0fccc679b349a1a7f41d#diff-997ac4e971e8a1108f07128317dfa5a16164555c9220704a45a2d7f26ff01eb0
As a workaround, you can "just" have one call:
services.AddNCronJob(
builder => builder
.AddJob<TestJob1>(o => o.WithCronExpression("0/1 * * * * *"))
.AddJob<TestJob2>(...)
);
@nulltoken we might wanna change that in the future to remove ambiguity (and make our code simpler)
As a workaround, you can "just" have one call:
services.AddNCronJob( builder => builder .AddJob<TestJob1>(o => o.WithCronExpression("0/1 * * * * *")) .AddJob<TestJob2>(...) );
Thanks, that could work.
Unfortunately I have decentralized my setup, where different parts of my code can just add stuff to the IOC container, including registering a job.
So, If you are going to fix it so it'll work in old way I'll just wait for the next release. If not I'll adjust my code. :-)
Describe the bug Prior to version 3.3.3 you could register multiple jobs by calling
AddNCronJob
multiple times.If I had a setup like this:
Current behavior Only
TestJob1
is executedExpected behavior Both
TestJob1
andTestJob2
should be executedVersion information
I think the change from
builder.RegisterJobs();
toservices.TryAddSingleton(jobRegistry);
in this commit is the cause of this behavior, but I'm not sure if it's intentional or a bug?If this is intentional I think the second call to
.AddNCronJob(...
should throw an exception.