You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,6 +50,8 @@ public class MyFirstTask : IRunnable
49
50
50
51
You can add any parameters to constructor, while they are resolvable from DI container (including scope-lifetime services, because new scope is created for every task run).
51
52
53
+
By default, new instance of `IRunnable` is created for every task run, but you may change lifetime in `AddTask` (see below). Use `IServiceProvider` passed to `RunAsync` to obtain scope-wide services if you force your task be singleton.
54
+
52
55
### 2. Register and start your task in `Startup.cs`
53
56
54
57
@@ -70,11 +73,28 @@ public void Configure(IApplicationBuilder app, ...)
70
73
71
74
And voila! Your task will run every 5 minutes. Until your application ends, of course.
72
75
76
+
`AddTask` adds your `MyFirstTask` to DI container with transient lifetime (new instance will be created for every task run). Pass desired lifetime to `AddTask()` to override: `services.AddTask<MyFirstTask>(ServiceLifetime.Singleton)`.
<Description>RecurrentTasks for .NET allows you to run simple recurrent background tasks with specific intervals, without complex frameworks, persistance, etc...</Description>
0 commit comments