Voyager.BackgroundWorker 1.6.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Voyager.BackgroundWorker --version 1.6.1                
NuGet\Install-Package Voyager.BackgroundWorker -Version 1.6.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="Voyager.BackgroundWorker" Version="1.6.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Voyager.BackgroundWorker --version 1.6.1                
#r "nuget: Voyager.BackgroundWorker, 1.6.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 Voyager.BackgroundWorker as a Cake Addin
#addin nuget:?package=Voyager.BackgroundWorker&version=1.6.1

// Install Voyager.BackgroundWorker as a Cake Tool
#tool nuget:?package=Voyager.BackgroundWorker&version=1.6.1                

Voyager.BackgroundWorker


The service continuously executes tasks based on time intervals. Protects from overlapping between new requests during the previous operation hasn't been finished. Can be configured to be triggered through http request. Can be extended for purposes to carry out customized control about exclusive executive the one task in an environment.

🏁 Getting Started

Prerequisites

The library coperate with the WebApplicationBuilder or HostApplicationBuilder. By the default, the hosts contain the required Dependency Injection.

🔧 How to start

To start using the service is required to implement the interface:

namespace Voyager.BackgroundWorker
{
  public interface WorkerTask
  {
    void Run(CancellationToken cancellationToken);
  }
}

Assume that is implemented the task:

public class MyTask : Voyager.BackgroundWorker.WorkerTask
{
  public void Run(CancellationToken cancellationToken)
  {
    // The logic goes here!
  }
}

Then service is configure by the method:

var appBuilder = Host.CreateDefaultBuilder(null);
appBuilder.ConfigureServices((services) =>
  {
    services.AddBackgroundWorker().AddWorker<MyTask>();
  });
host = appBuilder.Build();
host.Start();

Then the service starts executing the work task with a default interval every 60 seconds.

It is possoble to change the interval by setting:

services.AddBackgroundWorker()
.AddWorker<MyTask>()
.SetTimeUpToWakeUp(300);

🔧 How to trigger the task

It is an option to configure the service process with the additional requests of processing beyond times interval.

{
  var appBuilder = Host.CreateDefaultBuilder(null);
  appBuilder.ConfigureServices((services) =>
  {
    services.AddBackgroundWorker().AddWorker<MyTask>();
  });
  appBuilder.ConfigureWebHostDefaults((webConfigure) =>
  {
		webConfigure.UseStartup<Startup>();
  });
  host = appBuilder.Build();
  host.Start();
}

class Startup
{
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
    app.UseRouting();
    app.UseEndpoints(endpoints =>
    {
      endpoints.MapBackgroundWorker();
    });
  }
}

🔧 How to configure the external lock

After custom implementation the class Voyager.BackgroundWorker.ExternalLock. There is the possibility to use the logic in the service by registration through the method:

services.AddBackgroundWorker()
.AddWorker<MyTask>()
.AddExternalLock<MyLock>();

✍️ Authors

  • @andrzejswistowski - Idea & work. Please let me know if you find out an error or suggestions.

contributors.

🎉 Acknowledgements

  • Przemysław Wróbel - for the icon.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
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
1.8.2 551 11/21/2023
1.8.1 124 11/17/2023
1.7.2 119 11/13/2023
1.6.1 111 11/8/2023
1.5.0 211 4/19/2023
1.4.3 163 4/17/2023
1.4.2 190 4/14/2023
1.4.1 169 4/14/2023
1.4.0 189 4/14/2023