From febc8f774d0abb1edd59d4f23c1e34161f51db3a Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 11 May 2018 20:06:10 +0200 Subject: [PATCH] Start a dedicated thread per client. --- Frameworks/MQTTnet.NetStandard/Server/MqttServer.cs | 6 ++++-- Frameworks/MQTTnet.Netstandard/MQTTnet.NetStandard.csproj | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Frameworks/MQTTnet.NetStandard/Server/MqttServer.cs b/Frameworks/MQTTnet.NetStandard/Server/MqttServer.cs index b32869d..0324134 100644 --- a/Frameworks/MQTTnet.NetStandard/Server/MqttServer.cs +++ b/Frameworks/MQTTnet.NetStandard/Server/MqttServer.cs @@ -156,9 +156,11 @@ namespace MQTTnet.Server private void OnClientAccepted(object sender, MqttServerAdapterClientAcceptedEventArgs eventArgs) { - eventArgs.SessionTask = Task.Run( + eventArgs.SessionTask = Task.Factory.StartNew( () => _clientSessionsManager.RunSessionAsync(eventArgs.Client, _cancellationTokenSource.Token), - _cancellationTokenSource.Token); + _cancellationTokenSource.Token, + TaskCreationOptions.LongRunning, + TaskScheduler.Current); } } } diff --git a/Frameworks/MQTTnet.Netstandard/MQTTnet.NetStandard.csproj b/Frameworks/MQTTnet.Netstandard/MQTTnet.NetStandard.csproj index fc1e41a..8364378 100644 --- a/Frameworks/MQTTnet.Netstandard/MQTTnet.NetStandard.csproj +++ b/Frameworks/MQTTnet.Netstandard/MQTTnet.NetStandard.csproj @@ -22,7 +22,7 @@ false UAP,Version=v10.0 UAP - 10.0.16299.0 + 10.0.17134.0 10.0.10240.0 .NETCore v5.0 @@ -56,7 +56,7 @@ - +