hopefully fix mutex.release

This commit is contained in:
Mike Nolan 2023-03-17 07:46:13 -05:00
parent c89ba3031c
commit 94a39fbc9c
2 changed files with 17 additions and 3 deletions

View File

@ -530,7 +530,7 @@ namespace Ooui
// Create a new session and let it handle everything from here // Create a new session and let it handle everything from here
// //
try { 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, listenerContext.StartWebSocketConnection(session.Opened,
session.Arrived, session.Arrived,
session.Closed); } session.Closed); }

View File

@ -24,11 +24,11 @@ namespace Ooui
DateTime lastTransmitTime = DateTime.MinValue; DateTime lastTransmitTime = DateTime.MinValue;
readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / UI.MaxFps); readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / UI.MaxFps);
public WebSocketSession (Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action<string, Exception> errorLogger, CancellationToken serverToken) public WebSocketSession (UI ui,Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action<string, Exception> errorLogger, CancellationToken serverToken)
: base (element, disposeElementAfterSession, initialWidth, initialHeight, errorLogger) : base (element, disposeElementAfterSession, initialWidth, initialHeight, errorLogger)
{ {
this.ui = ui;
// //
// Create a new session cancellation token that will trigger // Create a new session cancellation token that will trigger
// automatically if the server shutsdown or the session shutsdown. // 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) { catch (Exception ex) {
Error ("Failed to send queued messages, aborting session", ex); Error ("Failed to send queued messages, aborting session", ex);
element.MessageSent -= handleElementMessageSent; element.MessageSent -= handleElementMessageSent;
@ -122,6 +135,7 @@ namespace Ooui
sendMsg = arg1; sendMsg = arg1;
Init(); Init();
} }
internal UI ui;
internal void Arrived(WebSocketMessage obj) internal void Arrived(WebSocketMessage obj)
{ {