Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 3.72 KB

README.md

File metadata and controls

80 lines (65 loc) · 3.72 KB

WickedFlame Broadcast


Build Status Build status Build status NuGet Version NuGet Version

Quality Gate Status Coverage Lines of Code

Codacy Badge

Simple and easy to use background task processing and message queue for .NET

Broadcast is a simple implementation for processing and scheduling tasks in the background without blocking the main thread.
Broadcast helps implement the Mediator or CQRS (Command- and Queryhandling) patterns easily.

Visit https://wickedflame.github.io/Broadcast/ for the full documentation.

Installation

Broadcast is available as a NuGet package

PM> Install-Package Broadcast

After installation setup the Processingserver in Startup.cs with a dashboard if desired

public void ConfigureServices(IServiceCollection services)
{
	...
	services.AddBroadcast();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    ...
	app.UseBroadcastServer();
	app.UseBroadcastDashboard();
}

Usage

Background Task processing

Processing a task in a async queue using the default Broadcaster

BackgroundTaskClient.Send(() => Trace.WriteLine("This is a basic task"));

Processing a task with a custom Broadcaster instance

var broadcaster = new Broadcaster();
broadcaster.Send(() => Trace.WriteLine("This is a basic task"));

Scheduleed Tasks

Schedule a task in a async queue using the default Broadcaster

BackgroundTaskClient.Schedule(() => Console.WriteLine("test"), TimeSpan.FromMinutes(1));

Schedule a task with a custom Broadcaster instance

var broadcaster = new Broadcaster();
broadcaster.Schedule(() => Console.WriteLine("test"), TimeSpan.FromMinutes(1));

Recurring Tasks

Add a recurring task to be processed in a async queue using the default Broadcaster

BackgroundTaskClient.Recurring("recurring", () => service.Recurring(DateTime.Now.ToString("o")), TimeSpan.FromMinutes(15));

Add a recurring task to be processed with a custom Broadcaster instance

var broadcaster = new Broadcaster();
broadcaster.Recurring("recurring", () => service.Recurring(DateTime.Now.ToString("o")), TimeSpan.FromMinutes(15));