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)