您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

32 行
956 B

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