From 94a39fbc9c4212f312894ee940b3e99495fd83ae Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Fri, 17 Mar 2023 07:46:13 -0500 Subject: [PATCH] hopefully fix mutex.release --- Ooui/UI.cs | 2 +- Ooui/WebSocketSession.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 3071a18..add80c6 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -530,7 +530,7 @@ namespace Ooui // Create a new session and let it handle everything from here // try { - var session = new WebSocketSession (element, disposeElementWhenDone, w, h, Error, serverToken); + var session = new WebSocketSession (this,element, disposeElementWhenDone, w, h, Error, serverToken); listenerContext.StartWebSocketConnection(session.Opened, session.Arrived, session.Closed); } diff --git a/Ooui/WebSocketSession.cs b/Ooui/WebSocketSession.cs index 4abb22d..e4fca77 100644 --- a/Ooui/WebSocketSession.cs +++ b/Ooui/WebSocketSession.cs @@ -24,11 +24,11 @@ namespace Ooui DateTime lastTransmitTime = DateTime.MinValue; readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / UI.MaxFps); - public WebSocketSession (Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action errorLogger, CancellationToken serverToken) + public WebSocketSession (UI ui,Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action errorLogger, CancellationToken serverToken) : base (element, disposeElementAfterSession, initialWidth, initialHeight, errorLogger) { - + this.ui = ui; // // Create a new session cancellation token that will trigger // automatically if the server shutsdown or the session shutsdown. @@ -110,6 +110,19 @@ namespace Ooui } } + catch ( System.AggregateException ex) + { + if(ex.ToString().Replace(" ","").ToLower().Contains("mutexisnotowned")) + { + if(ui.Verbose) + Console.WriteLine("Mutex is not owned error, continue going"); + }else{ + Error ("Failed to send queued messages, aborting session", ex); + element.MessageSent -= handleElementMessageSent; + sessionCts.Cancel (); + } + _=ex; + } catch (Exception ex) { Error ("Failed to send queued messages, aborting session", ex); element.MessageSent -= handleElementMessageSent; @@ -122,6 +135,7 @@ namespace Ooui sendMsg = arg1; Init(); } + internal UI ui; internal void Arrived(WebSocketMessage obj) {