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

SynchronizingSubscriptionsFailedHandlerDelegate.cs 1.0 KiB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Threading.Tasks;
  3. namespace MQTTnet.Extensions.ManagedClient
  4. {
  5. public class SynchronizingSubscriptionsFailedHandlerDelegate : ISynchronizingSubscriptionsFailedHandler
  6. {
  7. private readonly Func<ManagedProcessFailedEventArgs, Task> _handler;
  8. public SynchronizingSubscriptionsFailedHandlerDelegate(Action<ManagedProcessFailedEventArgs> handler)
  9. {
  10. if (handler == null) throw new ArgumentNullException(nameof(handler));
  11. _handler = context =>
  12. {
  13. handler(context);
  14. return Task.FromResult(0);
  15. };
  16. }
  17. public SynchronizingSubscriptionsFailedHandlerDelegate(Func<ManagedProcessFailedEventArgs, Task> handler)
  18. {
  19. _handler = handler ?? throw new ArgumentNullException(nameof(handler));
  20. }
  21. public Task HandleSynchronizingSubscriptionsFailedAsync(ManagedProcessFailedEventArgs eventArgs)
  22. {
  23. return _handler(eventArgs);
  24. }
  25. }
  26. }