mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 19:13:11 +08:00
Refactor naming for background tasks.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user