25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

ApplicationMessageSkippedHandlerDelegate.cs 1.2 KiB

2 yıl önce
1234567891011121314151617181920212223242526272829303132333435
  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 ApplicationMessageSkippedHandlerDelegate : IApplicationMessageSkippedHandler
  9. {
  10. private readonly Func<ApplicationMessageSkippedEventArgs, Task> _handler;
  11. public ApplicationMessageSkippedHandlerDelegate(Action<ApplicationMessageSkippedEventArgs> handler)
  12. {
  13. if (handler == null) throw new ArgumentNullException(nameof(handler));
  14. _handler = eventArgs =>
  15. {
  16. handler(eventArgs);
  17. return Task.FromResult(0);
  18. };
  19. }
  20. public ApplicationMessageSkippedHandlerDelegate(Func<ApplicationMessageSkippedEventArgs, Task> handler)
  21. {
  22. _handler = handler ?? throw new ArgumentNullException(nameof(handler));
  23. }
  24. public Task HandleApplicationMessageSkippedAsync(ApplicationMessageSkippedEventArgs eventArgs)
  25. {
  26. return _handler(eventArgs);
  27. }
  28. }
  29. }