Refactor naming for background tasks.

This commit is contained in:
Christian
2020-11-25 21:07:50 +01:00
parent 7738c5faa1
commit ec015e7620
6 changed files with 10 additions and 8 deletions
+4 -2
View File
@@ -5,11 +5,13 @@ namespace MQTTnet.Internal
{
public static class TaskExtensions
{
public static void Forget(this Task task, IMqttNetScopedLogger logger)
public static void RunInBackground(this Task task, IMqttNetScopedLogger logger = null)
{
task?.ContinueWith(t =>
{
logger.Error(t.Exception, "Unhandled exception.");
// Consume the exception first so that we get no exception regarding the not observed exception.
var exception = t.Exception;
logger?.Error(exception, "Unhandled exception in background task.");
},
TaskContinuationOptions.OnlyOnFaulted);
}