Files
mxaccessgw/src/MxGateway.Server/Workers/SystemWorkerProcessFactory.cs
T

27 lines
622 B
C#

using System.Diagnostics;
namespace MxGateway.Server.Workers;
/// <summary>
/// Factory that creates system processes for workers.
/// </summary>
public sealed class SystemWorkerProcessFactory : IWorkerProcessFactory
{
/// <inheritdoc />
public IWorkerProcess Start(ProcessStartInfo startInfo)
{
Process process = new()
{
StartInfo = startInfo,
};
if (!process.Start())
{
process.Dispose();
throw new InvalidOperationException("Worker process failed to start.");
}
return new SystemWorkerProcess(process);
}
}