first
This commit is contained in:
49
ManagementApp/AServices/Microsoft365Service.cs
Normal file
49
ManagementApp/AServices/Microsoft365Service.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using ManagementApp.AServices.Microsoft365;
|
||||
using ManagementApp.AServices.ThreadManage;
|
||||
using Microsoft.Identity.Web;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace ManagementApp.AServices
|
||||
{
|
||||
public class Microsoft365Service : BackgroundService, IDisposable
|
||||
{
|
||||
|
||||
private readonly IConcurrentTasks _task;
|
||||
public Microsoft365Service(IConcurrentTasks tasks) {
|
||||
_task = tasks;
|
||||
}
|
||||
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await DoWork(stoppingToken);
|
||||
}
|
||||
|
||||
private async Task DoWork(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
var workItem = await _task.First(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
await workItem(stoppingToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await base.StopAsync(stoppingToken);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user