A few times I've seen an exception in WaitForProcessAsync on Process.MainModule.FileName, where this code is reached while MainModule is still null (it gets set milliseconds later).
Updating the if (processes.Length > 0) to if (processes.Length > 0 && processes[0].MainModule != null) should fix it.
A few times I've seen an exception in WaitForProcessAsync on
Process.MainModule.FileName
, where this code is reached while MainModule is still null (it gets set milliseconds later).Updating the
if (processes.Length > 0)
toif (processes.Length > 0 && processes[0].MainModule != null)
should fix it.