Skip to content

v6.1: TRunnable can be an interface

Compare
Choose a tag to compare
@justdmitry justdmitry released this 12 Aug 17:45
· 26 commits to master since this release
v6.1.0

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;
}