This commit is contained in:
Florian Rappl
2026-09-04 14:05:36 +02:00
parent 042d8e6c70
commit 7cd552a78f
14 changed files with 159 additions and 17 deletions

View File

@@ -37,10 +37,18 @@
public ProcessRunner(string name)
{
this.Name = name;
this.ExitWaitTimeout = DefaultExitWaitTimeout;
}
public event EventHandler<EventArgs> ProcessExited;
/// <summary>Gets or sets the value <see cref="ExitWaitTimeout"/> is initialized with.</summary>
public static int DefaultExitWaitTimeout { get; set; } = 5000;
/// <summary>Gets or sets the time in milliseconds to wait for the process and its I/O to finish
/// after the exited event has been raised. Values of zero or less wait indefinitely.</summary>
public int ExitWaitTimeout { get; set; }
public bool IsDisposed { get; private set; }
private Process Process
@@ -498,8 +506,17 @@
{
try
{
var timeout = this.ExitWaitTimeout;
// This shouldn't throw here, but the mono process implementation doesn't always behave as it should.
this.process.WaitForExit();
if (timeout > 0)
{
this.process.WaitForExit(timeout);
}
else
{
this.process.WaitForExit();
}
}
catch (Exception ex)
{