https://github.com/imclint21/circle
.Net Core 3 Manager Background Service
https://github.com/imclint21/circle
background-jobs background-worker csharp grpc managed-services netcore netcore3 service worker-service
Last synced: 25 days ago
JSON representation
.Net Core 3 Manager Background Service
- Host: GitHub
- URL: https://github.com/imclint21/circle
- Owner: imclint21
- License: mit
- Created: 2020-04-05T03:33:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-05T18:20:37.000Z (over 5 years ago)
- Last Synced: 2025-02-13T17:29:57.514Z (5 months ago)
- Topics: background-jobs, background-worker, csharp, grpc, managed-services, netcore, netcore3, service, worker-service
- Language: C#
- Homepage:
- Size: 12.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
![]()
About Circle
.Net Core 3 Manager Background Service.
## Introduction
Circle is a .Net Core 3 Manager Background Service, that expose an API to handle it.
You simply need to add `AddCircle()` in the services collection.
### Startup.cs
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddCircle(options =>
{
options.Period = TimeSpan.FromSeconds(5);
options.UseHandler();
});
}
```### Create a Job
You need to create a new class that inherits from `IWorkHandler`, and write the task that need to be executed.
```csharp
public class Work : IWorkHandler
{
public void DoWork()
{
Console.WriteLine("Test!");
}
}
```
### Control the Job
You can use `CircleControl` class to start, stop or restart the service.
```csharp
public class HomeController : Controller
{
private readonly CircleControl _circle;public HomeController(CircleControl circle)
{
_circle = circle;
}public IActionResult Stop()
{
_circle.Stop();
return Ok();
}
}
```