Releases: justdmitry/RecurrentTasks
v7.0: net8.0 only, fully async
- New: TaskRunner does not create dedicated Task, instead it uses async/await (and ThreadPool), becoming more efficient;
- BREAKING: All previous framework support is dropped, only
net8.0
is supported now; - BREAKING:
Start()
now throwsInvalidOperationException
(instead ofArgumentOutOfRangeException
) whenOptions.FirstRunDelay
is negative; - Fix: RunStatus.LastRunTime now updated even after failed run;
v6.6: net8.0
- New TargetFramework added:
net8.0
. No any code changes, only framework reference. - Unsupported framework
net5.0
removed from target networks. Ping me if you still need it.
v6.5
v6.4.1: Bugfix
Fixes bug reported in #12. Now setting values for Interval
and FirstRunDelay
greater than 24d 20H (int.MaxValue in milliseconds) will throw ArgumentOutOfRange
exception.
v6.4: .NET 5.0
Library and test/samples now build for 3 frameworks: netstandard2.0
, netcoreapp3.1
and net5.0
v6.3: NetCore 3.1
- Framework moniker
netcoreapp3.0
updated tonetcoreapp3.1
, now library supportsnetstandard2.0
andnetcoreapp3.1
- Dependencies reorganized:
Microsoft.AspNetCore.Http.Abstractions
replaced withMicrosoft.Extensions.DependencyInjection.Abstractions
v6.2: Multi-framework, less dependencies
Microsoft.Extensions.Options
dependency removed- Library now built for both
netstandard2.0
andnetcoreapp3.0
framework monikers, with updated dependencies for last one.
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;
}
v6.0: Big changes
1. IApplicationLifetime
Main reason of this version is IApplicationLifetime
support (Issue #5) for better ASP.NET Core 2.1+ interaction. Now there is no more need for app.StartTask
calls in your Startup.Configure
- you need only services.AddTask<>(...)
in Startup.ConfigureServices
, and your task will be started/stopped automatically.
Doe to above, all configuration is moved to AddTask
, so simplest task registration look like:
services.AddTask<SampleTask>(o => o.AutoStart(15)); // 15 min, TimeSpan also allowed
All additional configuration (Culture
, FirstRunDelay
, before/after handlers etc) should be done here. Please note slight property name changes.
2. ITask.Options
All configurable task options now available from ITask.Options
property (e.g. for changing Interval from inside the task use currentTask.Options.Interval
instead of currentTask.Interval
) - that's breaking change you should pay attention to and update your tasks accordingly. Sorry.
3. ASP.NET Core 2.1 and netstandard2.0
As soon as IApplicationLifetime is supported only in ASP.NET Core 2.1 and above - depended libraries are upgraded to 2.1.0, and only netstandard2.0
target framework is supported (for netstartard1.0
and net46x
use previous version).
4. Minor improvements
- [Issue #6]
ITask
now haveRunnableType
read-only property, which returnstypeof(TRunnable)
. This may be used for logging purposes etc.
v5: RunAsync and more
IRunnable
changesvoid 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).IServiceProvider
added asRunAsync
parameter
You should use it for obtaining scoped-lifetime objects in case you force youIRunnable
be singleton (in AddTask, see below).
Startup.cs
changes- You may change lifetime of your
IRunnable
when callingAddTask<>
. It'sTransient
by default, but you may change it:services.AddTask<MyFirstTask>(ServiceLifetime.Singleton)
Important! No matter what lifetime yourIRunnable
has - everyRunAsync
is called inside new/own scope (disposed after run). UseIServiceProvider
passed as parameter for correct service resolution! - You may pass
CancellationToken
toStartTask
, and task will be stopped when this token got cancelled (issue #3)
- You may change lifetime of your
ITask
changes- Events
BeforeRun
,AfterRunSuccess
andAfterRunFail
replaced withasync Func
's - that's easier than async EventHandlers and EventArgs.
- Events