Closed serajoddin-aliabadi closed 2 months ago
There is no example of using Dependency Injection in ScheduleAsync method within docs. I do it this way:
ScheduleAsync
app.Services.UseScheduler(scheduler => { scheduler .ScheduleAsync(async () => { await using var scope = app.Services.CreateAsyncScope(); var job = scope.ServiceProvider.GetService<Coravel.Invocable.IInvocable>(); await job.Invoke(); }) .Weekly() .RunOnceAtStart(); });
Is it right? or any other better way?
Yes, that's basically how you would do this 👍.
Using invocables is the recommended way to schedule tasks, but ultimately it's your choice 👍
There is no example of using Dependency Injection in
ScheduleAsync
method within docs. I do it this way:Is it right? or any other better way?