25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
568 B

  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace MQTTnet.Internal
  5. {
  6. public sealed class AsyncAutoResetEvent : IDisposable
  7. {
  8. private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(0, 1);
  9. public Task WaitOneAsync(CancellationToken cancellationToken)
  10. {
  11. return _semaphore.WaitAsync(cancellationToken);
  12. }
  13. public void Set()
  14. {
  15. _semaphore.Release();
  16. }
  17. public void Dispose()
  18. {
  19. _semaphore?.Dispose();
  20. }
  21. }
  22. }