fix backgroundService exception handler

This commit is contained in:
Фролов 2021-05-24 16:30:35 +05:00
parent ae85cdedd5
commit 7f12f48cb9

View File

@ -15,22 +15,22 @@ namespace AsbCloudInfrastructure.Services
} }
protected override async Task ExecuteAsync(CancellationToken token) protected override async Task ExecuteAsync(CancellationToken token)
{
try
{ {
while (!token.IsCancellationRequested) while (!token.IsCancellationRequested)
{
try
{ {
if (tasksQueue.TryDequeue(out var item)) if (tasksQueue.TryDequeue(out var item))
await Task.Run(()=>item.action(item.id), token); await Task.Run(() => item.action(item.id), token);
else else
await Task.Delay(100, token); await Task.Delay(100, token);
} }
}
catch catch
{ {
//logger ? //logger ?
} }
} }
}
public override async Task StopAsync(CancellationToken token) public override async Task StopAsync(CancellationToken token)
{ {