TaskBucket 8.0.0.1
dotnet add package TaskBucket --version 8.0.0.1
NuGet\Install-Package TaskBucket -Version 8.0.0.1
<PackageReference Include="TaskBucket" Version="8.0.0.1" />
paket add TaskBucket --version 8.0.0.1
#r "nuget: TaskBucket, 8.0.0.1"
// Install TaskBucket as a Cake Addin #addin nuget:?package=TaskBucket&version=8.0.0.1 // Install TaskBucket as a Cake Tool #tool nuget:?package=TaskBucket&version=8.0.0.1
TaskBucket
TaskBucket adds the ability to run background tasks in AspNet. Each task being executed is given its own Scope, this scope exists during the lifetime of the background task being executed and is disposed of when the task ends.
Adding Task Bucket to AspNet
To enable Task Bucket simply call the below code.
public void ConfigureServices(IServiceCollection services)
{
services.AddTaskBucket();
// -- OR --
service.AddTaskBucket(o =>
{
// Sets the Time Zone.
o.TimeZone;
// Sets how many task instances can be executed at any given time.
o.WorkerThreadCount;
// Sets how often the Task Queue is checked for pending tasks.
o.SetTaskQueueCheckingInterval();
// Sets how often the Task Queue is trimmed.
o.SetTaskQueueTrimInterval();
});
}
Adding an Impromptu Task
public class FooService: IFooService
{
private readonly ITaskBucket _taskBucket;
public FooService(ITaskBucket taskBucket)
{
_taskBucket = taskBucket;
}
public void ExampleMethod()
{
_taskBucket.AddBackgroundTask<IBarService>
(
async b => await b.DoSomethingAsync()
);
}
}
Adding a Scheduled Task
In the below example, we're adding a scheduled task which will execute the DoSomethingAsync method every minute. We've also specified that only one instance of that task may be executing at any given time. If the schedule triggers the task and a previous instance is still running it will skipped.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.AddScheduledTask<IBarService>
(
// The action to be executed.
async b => await b.DoSomethingAsync(),
// The Task Options
o =>
{
// Only a single instance of this task may be executed at any given time.
o.InstanceLimitation = InstanceLimit.Single;
}
)
// The scheduling of the job.
// Run every minute.
.RunAsCronJob("*/1 * * * *");
}
Awaiting Background tasks
It is possible to await background tasks in TaskBucket.
public async Task ExampleMethodAsync()
{
ITask backgroundTask = _taskBucket.AddBackgroundTask<IBarService>
(
async b => await b.DoSomethingAsync()
);
await backgroundTask.WaitAsync();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Cronos (>= 0.8.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
-
net6.0
- Cronos (>= 0.8.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
-
net7.0
- Cronos (>= 0.8.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
-
net8.0
- Cronos (>= 0.8.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0.1 | 186 | 3/21/2024 |
5.0.0.1 | 478 | 7/5/2022 |
1.0.0.14-prerelease | 226 | 3/15/2021 |
1.0.0.13-prerelease | 218 | 3/12/2021 |
1.0.0.12-prerelease | 234 | 3/10/2021 |
1.0.0.11-prerelease | 214 | 3/10/2021 |
1.0.0.10-prerelease | 244 | 3/6/2021 |
1.0.0.9-prerelease | 219 | 2/20/2021 |
1.0.0.8-prerelease | 186 | 2/16/2021 |
1.0.0.7-prerelease | 201 | 2/16/2021 |
1.0.0.6-prerelease | 198 | 2/15/2021 |
1.0.0.5-prerelease | 210 | 2/15/2021 |
1.0.0.4-prerelease | 204 | 2/15/2021 |
1.0.0.3-prerelease | 216 | 2/15/2021 |
1.0.0.2-prerelease | 221 | 2/14/2021 |
1.0.0.1-prerelease | 225 | 2/14/2021 |