Skip to content

Commit

Permalink
Dependencies upgraded to 1.0.0 RTM
Browse files Browse the repository at this point in the history
  • Loading branch information
justdmitry committed Jun 28, 2016
1 parent 3d962d9 commit b1d519b
Show file tree
Hide file tree
Showing 8 changed files with 5,311 additions and 4,978 deletions.
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,60 @@ Each task is a separate `Task`, which sleeps in background for a while, wakes up

Ideal, 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.

Written for **ASP.NET vNext** (ASP.NET 5, ASP.NET Core 1).
Written for **ASP.NET Core** (ASP.NET 5, ASP.NET vNext).

## Main features

* Start and Stop you task at any time;
* Start and Stop your task at any time;
* First run (after Start) is delayed at random value (10-30 sec, customizable) to prevent app freeze during statup;
* Run "immediately" (without waiting for next scheduled time);
* Change run interval while running;
* `RunStatus` property (extendable) contains:
* last/next run times;
* last run result (success / exception);
* last success run time;
* last exception;
* total failed runs counter.
* last/next run times;
* last run result (success / exception);
* last success run time;
* last exception;
* total failed runs counter.

## Usage

### 1. Create new task class

public class MyFirstTask : TaskBase<TaskRunStatus>
```csharp
public class MyFirstTask : TaskBase<TaskRunStatus>
{
public MyFirstTask(ILoggerFactory loggerFactory, IServiceScopeFactory serviceScopeFactory)
: base(loggerFactory, TimeSpan.FromMinutes(5), serviceScopeFactory)
{
public MyFirstTask(ILoggerFactory loggerFactory, IServiceScopeFactory serviceScopeFactory)
: base(loggerFactory, TimeSpan.FromMinutes(5), serviceScopeFactory)
{
// Nothing
}
// Nothing
}

protected override void Run(IServiceProvider serviceProvider, TaskRunStatus runStatus)
{
protected override void Run(IServiceProvider serviceProvider, TaskRunStatus runStatus)
{
// Place your code here
}
}
}
```

### 2. Register and start your task in `Startup.cs`

public void ConfigureServices(IServiceCollection services)
{
...
services.AddSingleton<MyFirstTask>();
...
}

```csharp
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSingleton<MyFirstTask>();
...
}

public void Configure(IApplicationBuilder app, ...)
{
...
app.ApplicationServices.GetRequiredService<MyFirstTask>().Start();
...
}

public void Configure(IApplicationBuilder app, ...)
{
...
app.ApplicationServices.GetRequiredService<MyFirstTask>().Start();
...
}
```

And viola! Your task will run every 5 minutes (second param when calling :base constructor). Until you application alive, of course.


Expand All @@ -72,6 +77,8 @@ Target [framework/platform moniker](https://github.com/dotnet/corefx/blob/master

## Version history

* 2.3.0 (June 28, 2016)
* Dependencies upgraded to 1.0.0 RTM
* 2.2.0 (May 24, 2016)
* New `AfterRunFail` event with `Exception` info
* 2.1.0 (May 17, 2016)
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview1-002702"
"version": "1.0.0-preview2-003121"
}
}
30 changes: 11 additions & 19 deletions sample/RecurrentTasks.Sample/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,33 @@

"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"RecurrentTasks": "*"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
"version": "1.0.0-preview2-final"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
"version": "1.0.0-preview2-final"
}
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
"netcoreapp1.0": {}
},
"buildOptions": {
"emitEntryPoint": true,
Expand Down
Loading

0 comments on commit b1d519b

Please sign in to comment.