An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        



Circle



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();
}
}
```