L
lookaround
Hi everyone,
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:
try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}
p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}
If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"
Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).
The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.
I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)
Any help?
Thank you very much in advance for any idea!
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:
try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}
p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}
If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"
Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).
The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.
I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)
Any help?
Thank you very much in advance for any idea!