Releases: justdmitry/RecurrentTasks
Releases · justdmitry/RecurrentTasks
v5: RunAsync and more
IRunnablechangesvoid Run(...)changed toTask RunAsync(...)(from #1)
Now it's easier to write async code (but inside it's still one Task from thread pool that wait your code for complete and sleep between runs, no magic here).IServiceProvideradded asRunAsyncparameter
You should use it for obtaining scoped-lifetime objects in case you force youIRunnablebe singleton (in AddTask, see below).
Startup.cschanges- You may change lifetime of your
IRunnablewhen callingAddTask<>. It'sTransientby default, but you may change it:services.AddTask<MyFirstTask>(ServiceLifetime.Singleton)
Important! No matter what lifetime yourIRunnablehas - everyRunAsyncis called inside new/own scope (disposed after run). UseIServiceProviderpassed as parameter for correct service resolution! - You may pass
CancellationTokentoStartTask, and task will be stopped when this token got cancelled (issue #3)
- You may change lifetime of your
ITaskchanges- Events
BeforeRun,AfterRunSuccessandAfterRunFailreplaced withasync Func's - that's easier than async EventHandlers and EventArgs.
- Events
v4.0.0
- Breaking:
IRunnable.Runchanged fromvoid Run(ITask currentTask)tovoid Run(ITask currentTask, CancellationToken cancellationToken). Long-running implementations may use this cancellationToken to check ifStop()was called on task. - Code coverage reports added (via codecov.io)
v3.2.0
- Projects converted to VS 2017 and
*.csproj - Better logger name:
- Old:
RecurrentTasks.TaskRunner'1[[RecurrentTasks.Sample.SampleTask, RecurrentTasks.Sample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - New:
RecurrentTasks.TaskRunner<RecurrentTasks.Sample.SampleTask>
- Old:
NETStandard.Library (>= 1.6.0)is explicit dependency now (fornetstandard1.3)
BeforeRun and AfterRunSuccess events
- New events added to ITask:
BeforeRun,AfterRunSuccess(AfterRunFailalready exist) - Tests optimized, now takes only 12 seconds
Easier to write and test
Previous version was not friendly to unit-testing, this changed v3!
In v3, your task should not inherit from specific class - just implement IRunnable interface (with one Run method)!
Also, all services/options you need - accept them in class constructor (and don't forget to register in DI). Your task class now resolved from DI container on every run, and all dependencies are injected by DI infrastructure.
You will find your new tasks are much easier to unit-test.
v2.4.1: net451 and net46 are back
Target framework monikers net451 and net46 are back.
v2.4.0: ITask.AfterRunFail
Event AfterRunFail added to base ITask interface.
v2.3.0: Upgrade to RTM
Dependencies upgraded to 1.0.0 RTM versions
v2.2.0
- New event added:
AfterRunFailwithExceptioninfo
v2.1.0: Upgrade to RC2
- Target framework changed to
netstandard1.3(System.Threadingv4.0.11 is new dependency) - Other dependencies upgraded to RC2