AugusteVN.Worker
1.1.9
dotnet add package AugusteVN.Worker --version 1.1.9
NuGet\Install-Package AugusteVN.Worker -Version 1.1.9
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="AugusteVN.Worker" Version="1.1.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AugusteVN.Worker --version 1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AugusteVN.Worker, 1.1.9"
#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 AugusteVN.Worker as a Cake Addin #addin nuget:?package=AugusteVN.Worker&version=1.1.9 // Install AugusteVN.Worker as a Cake Tool #tool nuget:?package=AugusteVN.Worker&version=1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WorkerService
Re-usables for my multiple worker service setup that supports saving success or failure run to database.
WIP*
builder.Services
.AddOptions<WorkerConfig>
.BindConfiguration(nameof(WorkerConfig));
builder.Services.AddWorkerRunners(builder.Configuration, provider => provider.GetRequiredService<YourDbContext>());
// Or register separately
builder.Services.AddScoped<IWorkerDbContext>(provider => provider.GetRequiredService<YourDbContext>());
builder.Services.AddSingleton<IWorkerRunner, WorkerRunner>();
builder.Services.AddSingleton<IServiceRunner, ServiceRunner>();
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var delayInMinutes = new AmountOfHours {Amount = _workerConfig.DelayInHours}.ToMinutes();
var delayInMs = delayInMinutes * 1000;
var weekDays = new HashSet<DayOfWeek> {DayOfWeek.Wednesday};
while (!stoppingToken.IsCancellationRequested)
{
// Create scope, treat every run cycle as a request cycle.
using var scope = _serviceProvider.CreateScope();
await _workerRunner.RunWorkerOnScheduleAsync(new WorkerRunSettings
{
ServiceProvider = scope.ServiceProvider,
WorkerName = WorkerName,
WeekDays = weekDays,
FrequencyInMinutes = delayInMinutes // To make sure it doesn't run constantly on specified week days.
}, new[]
{
new ServiceRunSettings
{
WeekDays = weekDays,
RunnableService = _animalSummaryMailer
},
new ServiceRunSettings
{
RunnableService = _sheltersSubscribersSync
}
});
await Task.Delay(delayInMs, stoppingToken);
}
}
To see it in action: Multiple Worker Services Setup in C# .NET
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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.
-
net8.0
- AugusteVN.Database.EFCore (>= 1.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Update dependencies.