Closed serajoddin-aliabadi closed 9 months ago
Yes, that's basically how you would do this 👍.
Using invocables is the recommended way to schedule tasks, but ultimately it's your choice 👍
Yes, that's basically how you would do this 👍.
Using invocables is the recommended way to schedule tasks, but ultimately it's your choice 👍
Now, is it idiomatic to use Invocables, in a way where invoke returns a task (and hence is async)?
I mean, it's slightly confusing that there is also separate scheduleAsync method (which is harder to use with DI), alongside using invocable interface which has Task Invoke method.
Are these 2 equivalent in terms of how those operations are scheduled in thread pool, with a following example
public class Invocable : IInvocable {
public async Task Invoke()
{
await Task.Delay(1);
}
}
s.Schedule<Invocable>().Daily()
@jamesmh
They behave the same other than differences between using a class vs function. Ex. your function could have capture a variable from it's outer scope, etc.
But other wise they are scheduled the same on the thread pool, etc.
Using the function approach is probably best for simple things. Otherwise, invocables are the best option.
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?