Execute disconnected handler in new task.

This commit is contained in:
Christian Kratky
2019-06-06 19:32:00 +02:00
parent 60c6074953
commit c3c0dcf313
2 changed files with 22 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
using System.Threading.Tasks;
using MQTTnet.Diagnostics;
namespace MQTTnet.Internal
{
public static class TaskExtensions
{
public static void Forget(this Task task, IMqttNetChildLogger logger)
{
task?.ContinueWith(t =>
{
logger.Error(t.Exception, "Unhandled exception.");
},
TaskContinuationOptions.OnlyOnFaulted);
}
}
}