27 lines
622 B
C#
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);
|
|
}
|
|
}
|