Call dispose at the end of the session
This commit is contained in:
parent
84912bac46
commit
57b8aa15d2
|
@ -23,10 +23,13 @@ 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);
|
||||||
|
|
||||||
|
readonly bool disposeElementWhenDone;
|
||||||
|
|
||||||
public WebSocketSession (WebSocket webSocket, Element element, bool disposeElementWhenDone, double initialWidth, double initialHeight, CancellationToken serverToken)
|
public WebSocketSession (WebSocket webSocket, Element element, bool disposeElementWhenDone, double initialWidth, double initialHeight, CancellationToken serverToken)
|
||||||
: base (element, initialWidth, initialHeight)
|
: base (element, initialWidth, initialHeight)
|
||||||
{
|
{
|
||||||
this.webSocket = webSocket;
|
this.webSocket = webSocket;
|
||||||
|
this.disposeElementWhenDone = disposeElementWhenDone;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a new session cancellation token that will trigger
|
// Create a new session cancellation token that will trigger
|
||||||
|
@ -112,6 +115,15 @@ namespace Ooui
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
element.MessageSent -= handleElementMessageSent;
|
element.MessageSent -= handleElementMessageSent;
|
||||||
|
|
||||||
|
if (disposeElementWhenDone && (element is IDisposable disposable)) {
|
||||||
|
try {
|
||||||
|
disposable.Dispose ();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Error ("Failed to dispose of element", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue