TaskBucket 8.0.0.1

dotnet add package TaskBucket --version 8.0.0.1
NuGet\Install-Package TaskBucket -Version 8.0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TaskBucket" Version="8.0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TaskBucket --version 8.0.0.1
#r "nuget: TaskBucket, 8.0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 71 3/21/2024
5.0.0.1 445 7/5/2022
1.0.0.14-prerelease 202 3/15/2021
1.0.0.13-prerelease 193 3/12/2021
1.0.0.12-prerelease 204 3/10/2021
1.0.0.11-prerelease 186 3/10/2021
1.0.0.10-prerelease 217 3/6/2021
1.0.0.9-prerelease 194 2/20/2021
1.0.0.8-prerelease 165 2/16/2021
1.0.0.7-prerelease 173 2/16/2021
1.0.0.6-prerelease 169 2/15/2021
1.0.0.5-prerelease 186 2/15/2021
1.0.0.4-prerelease 179 2/15/2021
1.0.0.3-prerelease 194 2/15/2021
1.0.0.2-prerelease 192 2/14/2021
1.0.0.1-prerelease 198 2/14/2021