mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Fix handle creation wait loop in Terminal protocol
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
@@ -81,7 +81,20 @@ namespace mRemoteNG.Connection.Protocol.Terminal
|
||||
|
||||
_consoleControl.StartProcess(terminalExe, arguments);
|
||||
|
||||
while (!_consoleControl.IsHandleCreated) break;
|
||||
// Wait for the console control to create its handle
|
||||
int maxWaitMs = 5000; // 5 seconds timeout
|
||||
int startTicks = Environment.TickCount;
|
||||
while (!_consoleControl.IsHandleCreated &&
|
||||
Environment.TickCount < startTicks + maxWaitMs)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
|
||||
if (!_consoleControl.IsHandleCreated)
|
||||
{
|
||||
throw new Exception("Console control failed to create handle within timeout period");
|
||||
}
|
||||
|
||||
_handle = _consoleControl.Handle;
|
||||
NativeMethods.SetParent(_handle, InterfaceControl.Handle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user