Here is what I need to accomplish:
1. Start new process using Process.Start
2. Get it's handle and save to text file.
On next execution I read text file and see if process with same
name/handle still runs. However, I see that handle I obtain after
execution does not match handle that I get from list.
My code like this:
Process myGen = new Process();
myGen.StartInfo.FileName = Environment.CurrentDirectory +
"\\SampleGenerator.exe"; myGen.Start();
Thread.Sleep(1000); // I had to do this in order to avoid "Unable to
enumerate process
//modules" exception. Is there solution to this problem?
GeneratorProcess gp2 = new GeneratorProcess();
gp2.Name = myGen.ProcessName;
gp2.Handle = myGen.Handle.ToInt32(); //I get handle from process object
that I started
Process runs for over minute. When I execute code to enumerate
processes
Process[] RunningProcesses = Process.GetProcesses();
I get this process with completely different Handle.
What am I doing wrong?
TIA