The code (only part) works properly most of the time, but it sometimes just hang there and the lines after try...catch block seem not to be called even if the process in the task manager doesn't exist any more.
Because most of the time there's just no problem with it, I can't reproduce the issue while debugging. Can any one give me a hint why or on what condition will this happen?
try {
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit(settings.PlinkConnectTimeout * 1000);
if (process != null && !process.HasExited) {
if (IsConnected) {
process.WaitForExit();
}
else {
process.Kill();
}
}
}
catch { }
IsConnected = false;
IsConnecting = false;
Disconnected(isLastSuccess, isReconnect);