intro-skipper/IntroSkipper/ScheduledTasks/ScheduledTaskSemaphore.cs

25 lines
504 B
C#
Raw Normal View History

using System;
using System.Threading;
namespace IntroSkipper.ScheduledTasks;
internal sealed class ScheduledTaskSemaphore : IDisposable
{
private static readonly SemaphoreSlim _semaphore = new(1, 1);
private ScheduledTaskSemaphore()
{
}
2024-09-23 19:45:16 +02:00
public static IDisposable Acquire(CancellationToken cancellationToken)
{
2024-09-23 19:45:16 +02:00
_semaphore.Wait(cancellationToken);
2024-05-10 06:35:52 +02:00
return new ScheduledTaskSemaphore();
}
public void Dispose()
{
2024-09-23 19:45:16 +02:00
_semaphore.Release();
}
}