CommandScheduler 2.2.3

.NET Standard 2.1
dotnet add package CommandScheduler --version 2.2.3
NuGet\Install-Package CommandScheduler -Version 2.2.3
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="CommandScheduler" Version="2.2.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CommandScheduler --version 2.2.3
#r "nuget: CommandScheduler, 2.2.3"
#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 CommandScheduler as a Cake Addin
#addin nuget:?package=CommandScheduler&version=2.2.3

// Install CommandScheduler as a Cake Tool
#tool nuget:?package=CommandScheduler&version=2.2.3

Integrate MediatR with Hangfire

To schedule your commands, execute them parallel with retry option and monitor them. Hangfire gives me all these kind of features but You have to have public method which You have to pass to Hangifre method (for example BackgroundJob.Enqueue). This is a problem – with mediator pattern You cannot pass public method of handler because You have decoupled it from invoker. So You need special way to integrate MediatR with Hangfire without affecting basic assumptions.

I presented the way of processing commands asynchronously using MediatR and Hangfire. With this approach we have:

  1. Decoupled invokers and handlers of commands.
  2. Scheduling commands mechanism.
  3. Invoker and handler of command may be other processes.
  4. Commands execution monitoring.
  5. Commands execution retries mechanism.

These benefits are very important during development using eventual consistency approach. We have more control over commands processing and we can react quickly if problem will appear.

For this, In CommandScheduler we difined 4 classes:

  • CommandsScheduler serializes commands and sends them to Hangfire.
  • CommandsExecutor responods to Hangfire jobs execution, deserializes commands and sends them to handlers using MediatR.
  • MediatorSerializedObject wrapper class for serialized/deserialized commands with additional properties – command type and additional description.
  • MediatorExtension extension methods for IMediator
public class MyMController : Controller
    private IMediator _mediator;
    public MyMicroserviceController(IMediator mediator)
        _mediator = mediator;
    public async Task<IActionResult> Post([FromBody] TestCommand testCommand)

      return Ok();

And our commands are scheduled, invoked and monitored by Hangfire.


Install the package via NuGet first: Install-Package CommandScheduler

Or via the .NET Core command line interface: dotnet add package CommandScheduler

Either commands, from Package Manager Console or .NET Core CLI, will download and install CommandScheduler and all required dependencies.

The CommandScheduler includes a IServiceCollection.AddCommandsScheduler(Connection, Assembly) extension method, allowing you to register CommandScheduler.

builder.Services.AddCommandsScheduler(builder.Configuration.GetConnectionString("HangfireConnection"), typeof(Program));
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
2.2.3 333 9/23/2022
2.2.2 291 9/23/2022
2.1.2 282 9/13/2022
2.1.1 279 9/13/2022
2.1.0 283 9/13/2022
2.0.0 776 8/10/2021
1.0.5 666 1/21/2020
1.0.4 417 12/18/2019
1.0.3 416 12/4/2019
1.0.2 420 12/2/2019
1.0.1 389 12/2/2019
1.0.0 383 12/1/2019