For reasons of memory isolation and stability I need to execute some methods/classes as sub-processes, not threads. I found the following library that allows me to do just that: https://github.com/tmds/Tmds.ExecFunction.
However, I can't seem to find a way to get the process ID of the child process.
ExecFunction.Run(() => new NewSubProcessClass());
The code above will generate a new process and will even generate console output in a Linux Docker container. The problem is, that I have no process ID.
public static Process Start(Action action, Action<ExecFunctionOptions> configure = null);
The method I quoted above looked like it should do the trick, however, when I replace
ExecFunction.Run(() => new NewSubProcessClass());
with
Process process = ExecFunction.Start(() => new NewSubProcessClass());
I no longer get any console output.
UPDATE 0:
The suggestion from @bazzilic
process.WaitForExit();
is the solution to the problem.