mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
27 lines
568 B
C#
27 lines
568 B
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MQTTnet.Internal
|
|
{
|
|
public sealed class AsyncAutoResetEvent : IDisposable
|
|
{
|
|
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(0, 1);
|
|
|
|
public Task WaitOneAsync(CancellationToken cancellationToken)
|
|
{
|
|
return _semaphore.WaitAsync(cancellationToken);
|
|
}
|
|
|
|
public void Set()
|
|
{
|
|
_semaphore.Release();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_semaphore?.Dispose();
|
|
}
|
|
}
|
|
}
|