fix crash if XenCenterMain.exe fails to start

Add some more error handling and error messages.
This commit is contained in:
cocoon 2019-05-23 11:25:30 +02:00 committed by GitHub
parent 834a5beda0
commit ec938ed21b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,15 +105,50 @@ namespace splash_xcp_ng
int counter = 0;
while (proc == null || string.IsNullOrEmpty(proc.MainWindowTitle))
while (proc == null)
{
System.Threading.Thread.Sleep(sleepMilliseconds);
if(proc != null) proc.Refresh();
if (proc != null) proc.Refresh();
counter++;
if ((counter * sleepMilliseconds) >= max) break;
}
if (proc == null)
{
MessageBox.Show("[ERROR] Something went wrong, program did not start in time: " + Environment.NewLine + exeFullPath);
}
else
{
if (proc.HasExited)
{
MessageBox.Show("[ERROR] Something went wrong, program stopped already: " + Environment.NewLine + exeFullPath);
}
else
{
for (int i = 1; i * sleepMilliseconds <= max; i++)
{
try
{
while (string.IsNullOrEmpty(proc.MainWindowTitle))
{
System.Threading.Thread.Sleep(sleepMilliseconds);
if (proc != null) proc.Refresh();
counter++;
if ((counter * sleepMilliseconds) >= max) break;
}
}
catch (Exception ex)
{
MessageBox.Show("[ERROR] Something went wrong, failed to start: " + Environment.NewLine + exeFullPath);
Exit();
}
}
}
}
Exit();
}