alexisbmason
New Member
Hi fellow programmers,I am scratching my head over this one. I am using the following method to start a process. The first is wkhtmltoimage.exe and then wkhtmltopdf.exe. Everything works as expected, except that \[code\]Process_Exited\[/code\] is not always called. During a single run of my program, where I pressed the appropriate button several times, I had all possible variations:
Nothing is reproducible, every run is different. This is my first try with processes, maybe I am doing something wrong. Solving this problem is not vital for my application, luckily.\[code\]protected Process StartProcess(string FileName, string Arguments){ ProcessStartInfo MyStartInfo = new ProcessStartInfo(FileName, Arguments) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true }; Process Proc = new Process { StartInfo = MyStartInfo }; Proc.EnableRaisingEvents = true; Proc.Exited += (sender, name) => Process_Exited(Proc, Proc.ProcessName); Proc.Start(); return Proc;}protected void Process_Exited(object sender, string ProcessName){ Debug.WriteLine("Process_Exited: " + ProcessName);}\[/code\]
- Only wkhtmltoimage raised the event
- only wkhtmltopdf raised the event
- both did
- the event wasn't raised at all.
Nothing is reproducible, every run is different. This is my first try with processes, maybe I am doing something wrong. Solving this problem is not vital for my application, luckily.\[code\]protected Process StartProcess(string FileName, string Arguments){ ProcessStartInfo MyStartInfo = new ProcessStartInfo(FileName, Arguments) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true }; Process Proc = new Process { StartInfo = MyStartInfo }; Proc.EnableRaisingEvents = true; Proc.Exited += (sender, name) => Process_Exited(Proc, Proc.ProcessName); Proc.Start(); return Proc;}protected void Process_Exited(object sender, string ProcessName){ Debug.WriteLine("Process_Exited: " + ProcessName);}\[/code\]