Update ProtocolBase.cs

Do not attempt to dispose the control if the control is already closed, closing or disposed.
This commit is contained in:
BlueBlock
2023-03-14 04:44:42 -04:00
parent 53acc94976
commit 6a3115b80a

View File

@@ -5,6 +5,7 @@ using System.Threading;
using System.Windows.Forms;
using mRemoteNG.UI.Tabs;
using System.Runtime.Versioning;
using mRemoteNG.UI.Forms;
// ReSharper disable UnusedMember.Local
@@ -88,8 +89,7 @@ namespace mRemoteNG.Connection.Protocol
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("Couldn't focus Control (Connection.Protocol.Base)",
ex);
Runtime.MessageCollector.AddExceptionStackTrace("Couldn't focus Control (Connection.Protocol.Base)", ex);
}
}
@@ -233,6 +233,12 @@ namespace mRemoteNG.Connection.Protocol
private void DisposeControl()
{
// do not attempt to dispose the control if the control is already closed, closing or disposed
if (Control == null || !Control.IsAccessible || Control.IsDisposed)
{
return;
}
if (Control.InvokeRequired)
{
var s = new DisposeControlCB(DisposeControl);