Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samhammerag/samhammer.queuedhostedservice
hostedservice to execute background tasks in order
https://github.com/samhammerag/samhammer.queuedhostedservice
net-core-project-lib
Last synced: about 1 month ago
JSON representation
hostedservice to execute background tasks in order
- Host: GitHub
- URL: https://github.com/samhammerag/samhammer.queuedhostedservice
- Owner: SamhammerAG
- License: mit
- Created: 2020-10-21T11:59:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-08T11:11:38.000Z (10 months ago)
- Last Synced: 2024-11-30T00:06:14.926Z (about 1 month ago)
- Topics: net-core-project-lib
- Language: C#
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Samhammer.QueuedHostedService
This package provides a hosted queue service to execute background tasks in order.
The implementation is based on this documentation:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio#queued-background-tasks#### How to add this to your project:
- reference this nuget package: https://www.nuget.org/packages/Samhammer.QueuedHostedService/#### How to use:
Register the background queue service in startup:
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddBackgroundQueue();
}
```Add tasks to the queue:
```csharp
public class SampleService
{
private IBackgroundTaskQueue BackgroundQueue { get; }
public SampleService(IBackgroundTaskQueue backgroundQueue)
{
BackgroundQueue = backgroundQueue;
}
public SampleMethod() {
BackgroundQueue.Enqueue(cancellationToken =>
{
Console.WriteLine("Executing background task.");
return Task.CompletedTask;
});
}
}
```## Contribute
#### How to publish a nuget package
- Create a tag and let the github action do the publishing for you