From 9308b9495f54918e709cfbefa4dad19eb676ff0b Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Fri, 17 Mar 2023 08:05:48 -0500 Subject: [PATCH] hopefully fix mutex.release --- Ooui/Ooui.csproj | 2 +- Ooui/Session.cs | 11 +++++++++++ Ooui/WebSocketSession.cs | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Ooui/Ooui.csproj b/Ooui/Ooui.csproj index a07f723..8dbfbc9 100644 --- a/Ooui/Ooui.csproj +++ b/Ooui/Ooui.csproj @@ -1,6 +1,6 @@  - 1.0.0.2 + 1.0.0.3 A tesses webserver port of https://github.com/praeclarum/Ooui Ooui;UI;CrossPlatform Icon.png diff --git a/Ooui/Session.cs b/Ooui/Session.cs index 0f7864c..3c7eb2f 100644 --- a/Ooui/Session.cs +++ b/Ooui/Session.cs @@ -13,6 +13,17 @@ namespace Ooui protected readonly List queuedMessages = new List (); + protected readonly System.Threading.SemaphoreSlim slimSema=new System.Threading.SemaphoreSlim(0,1); + + protected void LockQueue() + { + slimSema.Wait(); + } + protected void UnlockQueue() + { + slimSema.Release(); + } + protected readonly bool disposeElementAfterSession; readonly Action errorLogger; diff --git a/Ooui/WebSocketSession.cs b/Ooui/WebSocketSession.cs index e4fca77..5837ac8 100644 --- a/Ooui/WebSocketSession.cs +++ b/Ooui/WebSocketSession.cs @@ -92,7 +92,7 @@ namespace Ooui // var messagesToSend = new List (); - lock (queuedMessages) { + LockQueue(); messagesToSend.AddRange (queuedMessages); queuedMessages.Clear (); @@ -107,7 +107,7 @@ namespace Ooui //Console.WriteLine ("TRANSMIT " + json); sendMsg?.Invoke(WebSocketMessage.Create(json)); //task = webSocket.SendAsync (outputBuffer, WebSocketMessageType.Text, true, token).ConfigureAwait (false); - } + UnlockQueue(); } catch ( System.AggregateException ex)