DocSpace-client/common/services/ASC.Webhooks.Service/WebhookHostedService.cs

49 lines
1.1 KiB
C#
Raw Normal View History

2021-07-31 17:12:41 +00:00
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using Microsoft.Extensions.Hosting;
2021-08-26 18:43:41 +00:00
namespace ASC.Webhooks.Service
{
[Singletone]
public class WebhookHostedService : IHostedService
{
private WorkerService workerService;
2021-08-03 16:26:28 +00:00
private BuildQueueService buildQueueService;
2021-08-03 16:26:28 +00:00
public WebhookHostedService(WorkerService workerService,
BuildQueueService buildQueueService)
{
2021-08-03 16:26:28 +00:00
this.workerService = workerService;
this.buildQueueService = buildQueueService;
}
public Task StartAsync(CancellationToken cancellationToken)
{
2021-08-03 16:26:28 +00:00
workerService.Start(cancellationToken);
buildQueueService.Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
if (workerService != null)
{
workerService.Stop();
workerService = null;
}
2021-08-03 16:26:28 +00:00
if (buildQueueService != null)
{
2021-08-03 16:26:28 +00:00
buildQueueService.Stop();
}
return Task.CompletedTask;
}
}
}