From f78bb036062669708449743d9d89f8c6dd73296e Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 25 Apr 2020 16:05:51 -0700 Subject: [PATCH] Fix multiple threads reading stream. --- Agent/Services/ChatClientService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Agent/Services/ChatClientService.cs b/Agent/Services/ChatClientService.cs index 270a1182a..859bf07af 100644 --- a/Agent/Services/ChatClientService.cs +++ b/Agent/Services/ChatClientService.cs @@ -52,6 +52,7 @@ public async Task SendMessage(string message, string orgName, string senderConne return; } chatSession = new ChatSession() { PipeStream = clientPipe, ProcessID = procID }; + _ = Task.Run(async () => { await ReadFromStream(chatSession.PipeStream, senderConnectionID, hubConnection); }); ChatClients.Add(senderConnectionID, chatSession, CacheItemPolicy); } @@ -69,8 +70,6 @@ public async Task SendMessage(string message, string orgName, string senderConne await sw.WriteLineAsync(message); await sw.FlushAsync(); } - - _ = Task.Run(async () => { await ReadFromStream(chatSession.PipeStream, senderConnectionID, hubConnection); }); } } catch (Exception ex)