TaskExtensions.cs 436 B

1234567891011121314151617
  1. using MQTTnet.Diagnostics;
  2. using System.Threading.Tasks;
  3. namespace MQTTnet.Internal
  4. {
  5. public static class TaskExtensions
  6. {
  7. public static void Forget(this Task task, IMqttNetLogger logger)
  8. {
  9. task?.ContinueWith(t =>
  10. {
  11. logger.Error(t.Exception, "Unhandled exception.");
  12. },
  13. TaskContinuationOptions.OnlyOnFaulted);
  14. }
  15. }
  16. }