First of all: I know this is pretty old, but no answer has been accepted so far, so maybe my approach will help someone else. :)
What I did to solve this problem:
process.Start(); while (true) { try { var time = process.StartTime; break; } catch (Exception) {} }
The association var time = process.StartTime will throw an exception until the process starts. Therefore, as soon as this passes, we can safely assume that the process is running and continue to work with it. I use this to wait for the Java process to start, as it takes some time. Thus, it should be independent of which machine the application is running on, and not using Thread.Sleep() .
I understand that this is not a very clean solution, but the only thing that should be independent of the performance that I could think of.
RhodryCZ Mar 23 '17 at 19:52 2017-03-23 โโ19:52
source share