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.
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();
}
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"));
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));
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));