@@ -6,55 +6,60 @@ Each task is a separate `Task`, which sleeps in background for a while, wakes up
66
77Ideal, when you don't need to run many/heavy tasks and don't want to use "big" solutions with persistence and other bells and whistles.
88
9- Written for ** ASP.NET vNext ** (ASP.NET 5, ASP.NET Core 1 ).
9+ Written for ** ASP.NET Core ** (ASP.NET 5, ASP.NET vNext ).
1010
1111## Main features
1212
13- * Start and Stop you task at any time;
13+ * Start and Stop your task at any time;
1414* First run (after Start) is delayed at random value (10-30 sec, customizable) to prevent app freeze during statup;
1515* Run "immediately" (without waiting for next scheduled time);
1616* Change run interval while running;
1717* ` RunStatus ` property (extendable) contains:
18- * last/next run times;
19- * last run result (success / exception);
20- * last success run time;
21- * last exception;
22- * total failed runs counter.
18+ * last/next run times;
19+ * last run result (success / exception);
20+ * last success run time;
21+ * last exception;
22+ * total failed runs counter.
2323
2424## Usage
2525
2626### 1. Create new task class
2727
28- public class MyFirstTask : TaskBase<TaskRunStatus>
28+ ``` csharp
29+ public class MyFirstTask : TaskBase <TaskRunStatus >
30+ {
31+ public MyFirstTask (ILoggerFactory loggerFactory , IServiceScopeFactory serviceScopeFactory )
32+ : base (loggerFactory , TimeSpan .FromMinutes (5 ), serviceScopeFactory )
2933 {
30- public MyFirstTask(ILoggerFactory loggerFactory, IServiceScopeFactory serviceScopeFactory)
31- : base(loggerFactory, TimeSpan.FromMinutes(5), serviceScopeFactory)
32- {
33- // Nothing
34- }
34+ // Nothing
35+ }
3536
36- protected override void Run(IServiceProvider serviceProvider, TaskRunStatus runStatus)
37- {
37+ protected override void Run (IServiceProvider serviceProvider , TaskRunStatus runStatus )
38+ {
3839 // Place your code here
39- }
4040 }
41+ }
42+ ```
4143
4244### 2. Register and start your task in ` Startup.cs `
4345
44- public void ConfigureServices(IServiceCollection services)
45- {
46- ...
47- services.AddSingleton<MyFirstTask>();
48- ...
49- }
46+
47+ ``` csharp
48+ public void ConfigureServices (IServiceCollection services )
49+ {
50+ .. .
51+ services .AddSingleton <MyFirstTask >();
52+ .. .
53+ }
5054
51- public void Configure(IApplicationBuilder app, ...)
52- {
53- ...
54- app.ApplicationServices.GetRequiredService<MyFirstTask>().Start();
55- ...
56- }
57-
55+ public void Configure (IApplicationBuilder app , .. .)
56+ {
57+ .. .
58+ app .ApplicationServices .GetRequiredService <MyFirstTask >().Start ();
59+ .. .
60+ }
61+ ```
62+
5863And viola! Your task will run every 5 minutes (second param when calling : base constructor). Until you application alive, of course.
5964
6065
@@ -72,6 +77,8 @@ Target [framework/platform moniker](https://github.com/dotnet/corefx/blob/master
7277
7378## Version history
7479
80+ * 2.3.0 (June 28, 2016)
81+ * Dependencies upgraded to 1.0.0 RTM
7582* 2.2.0 (May 24, 2016)
7683 * New ` AfterRunFail ` event with ` Exception ` info
7784* 2.1.0 (May 17, 2016)
0 commit comments