You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.2 KiB

  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Threading.Tasks;
  6. namespace MQTTnet.Extensions.ManagedClient
  7. {
  8. public class SynchronizingSubscriptionsFailedHandlerDelegate : ISynchronizingSubscriptionsFailedHandler
  9. {
  10. private readonly Func<ManagedProcessFailedEventArgs, Task> _handler;
  11. public SynchronizingSubscriptionsFailedHandlerDelegate(Action<ManagedProcessFailedEventArgs> handler)
  12. {
  13. if (handler == null) throw new ArgumentNullException(nameof(handler));
  14. _handler = context =>
  15. {
  16. handler(context);
  17. return Task.FromResult(0);
  18. };
  19. }
  20. public SynchronizingSubscriptionsFailedHandlerDelegate(Func<ManagedProcessFailedEventArgs, Task> handler)
  21. {
  22. _handler = handler ?? throw new ArgumentNullException(nameof(handler));
  23. }
  24. public Task HandleSynchronizingSubscriptionsFailedAsync(ManagedProcessFailedEventArgs eventArgs)
  25. {
  26. return _handler(eventArgs);
  27. }
  28. }
  29. }