Files
MikaltoResort/ManagementApp/AServices/Microsoft365Service.cs
2025-06-04 14:17:32 +07:00

50 lines
1.3 KiB
C#

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