v6.1: TRunnable can be an interface
Now you can call AddTask
on interface (inherited from IRunnable
) and register it's implementation later manually. This may be useful when you have several versions of same task and need to choose correct one on startup depending on configuration.
services.AddTask<IFileProcessorTask>(o => o.AutoStart(TimeSpan.FromMinutes(1)));
switch (configuration["FileProcessingMode"])
{
case "Network":
services.AddTransient<IFileProcessorTask, NetworkFileProcessorTask>();
break;
default:
services.AddTransient<IFileProcessorTask, LocalFileProcessorTask>();
break;
}