I am working on worker service using Coraval library, following this article. From Program.cs class I want to pass Invocable class and Interface but not sure how to pass Interface. This is my Program.cs class code
public class Program
{
public static void Main(string[] args)
{
IHost host = CreateHostBuilder(args).Build();
host.Services.UseScheduler(scheduler => {
// Remind schedular to repeat the same job in every five-second
scheduler
.Schedule<ReprocessInvocable>()
.EveryTenSeconds();
});
host.Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddScheduler();
// register job with container
services.AddTransient<ReprocessInvocable>();
});
}
Invocable class
public class ReprocessInvocable : IInvocable
{
IForceReprocess _forceReprocess;
public ReprocessInvocable(IForceReprocess forceReprocess)
{
_forceReprocess = forceReprocess;
}
public async Task Invoke()
{
_forceReprocess.GetFailedProduct();
Console.WriteLine("Works fine... my first schedule job.......!!!" + DateTime.Now.ToString());
//return Task.CompletedTask;
}
}
May be I need pass interface here services.AddTransient<ReprocessInvocable>();