Hi all
I am workign on a program that acts as an installer for multiple programs. My program simple runs other install programs as processes from C#.
I was trying to use the process.Exited event in order to trigger the next step of the installation, but this event never seems to get triggered even when the processes is finished and terminates itself
Does anyone know why this is and a solution to it. I need a way to control the different steps in a linear fashion and prevent multiple processes from running simultaneously. I would use the .WaitForExit() method but this prevents my windows form from refreshing and placing a different object on top of it makes it look like the form is not responding.
Thanks for the help

C# Process Events
J.C.
After the event has been triggered I am unable to change any of the properties of the form objects. It says that they were created in another thread.
I am using a P4 with hyperthreadign but I have not been doin any thread programming. I tried running the program with CheckForIllegalCrossThreadCalls = false
the program could run but when i tried opening a new form from the event funtion (or from a function called by the event function) the form would not load properly and would stop responding
Does anyone have an ideas what is causing this and what the processes have to do with it.
Thanks.
Dmitry_
It is because the events are being run on another thread you have to push the calls back to the main thread using control.invoke() http://weblogs.asp.net/justin_rogers/articles/126345.aspx includes a detailed explanation.
mscheuner_garaio
well it must be something else making my app crash on the old P3 computer then
Thanks for the help
Krista
I am having the same kind of problem. I have a form with a button and a progressbar. I am using Process.Start() for two(2) processes under the button_Click() event. What I want to do is to show the status through progrssbar after each process is completed. I am using WaitForExit() for the process to exit. But the prgress bar does not get updated after each call to Process.Start() . It looks like that the main form looses the focus when a process is started and never gets it back untill all the processes are completed.
I tried this.Active() on the form after WaitForExit(), it didn't work out.
I tried
prcA1.Exited += new EventHandler(ProcessExitedEvent), but it did not work either.
Any clue how to update the progress bar on the form after each Processs.Start() call.
Here is the sample code: with Progressbar1.Step =25;
private void Install_Click(object sender, System.EventArgs e) { // FPM Installation Process prcA1 = Process.Start(@"A1.exe"); //prcA1.Exited += new EventHandler(ProcessExitedEvent); //prcA1.EnableRaisingEvents = true; prcA1.WaitForExit(); this.Activate(); progressBar1.PerformStep(); // Driver Installation Process prcB1 = Process.Start(@"B1.exe"); // prcB1.Exited += new EventHandler(ProcessExitedEvent); // prcB1.EnableRaisingEvents = true; prcDriverB1.WaitForExit(); progressBar1.PerformStep(); // Driver Installation Process prcC1 = Process.Start(@"C1.exe"); // prcC1.Exited += new EventHandler(ProcessExitedEvent); // prcC1.EnableRaisingEvents = true; prcC1.WaitForExit(); progressBar1.PerformStep(); // Driver Installation Process prcD1 = Process.Start(@"D1.exe"); // prcD1.Exited += new EventHandler(ProcessExitedEvent); // prcD1.EnableRaisingEvents = true; prcD1.WaitForExit(); progressBar1.PerformStep(); } //private void ProcessExitedEvent(object sender, System.EventArgs e) //{ //this.Activate(); //progressBar1.PerformStep(); //}SamCKayak
Thanks for the tip
geanyee
All computers that run a .NET environment support multiple threads.
kenlefeb
meatz
but is there a way to run the events on the same thread
and if not what is the result if the program was run on a computer without multi-threading capabilities
I am not sure of the systems that will be running this program so I would like to keep it single threaded if possible