MTSkull Posted September 18, 2006 Posted September 18, 2006 I have written a program that is kind of a wrapper for a low level program. The Heirarchie looks something like this. Batch file for USB port Calls EEprom Loader Calls Errorlevel Processor (C#) C# GUI Calls Bat Files for 4 usb ports in order The gui program monitors the process to see when the eeprom loader has finished, when it has finished it reads the text files created by the Errorlevel processor, displays the results then runs the next bat file. The problem I am having is when the GUI detects that the loader has finished and starts the next batch file it should update its display to show what happened and to tell the user it has started on the next port. What happens is the gui losses focus and then never updates until the test has finished. Despite my having put this.update in the loop. The Gui window gets pushed to the back after the eeprom loader starts, so... Do i need to set the gui window to top to get it to continue updating or can I push it to the top at the end of its loop so it will update and then let it fall back down after the next loader starts. Hopefully this is not clear as mud. MT //Pseudoish code of what I am doing for(int x=1;x<=4;x++) { Process.Start("USB"+x.tostring()+".bat"); BatRunning = true While (BatRunning==true) { activeProcesses = Process.GetProcessesByName("cprogcfz"); if (activeProcesses.GetUpperBound(0) < 0) break; Thread.sleep(500); } this.label.text = TestResult; this.update; } //Obviosly this psuedo code will not work but will hopefully give you an idea of what i am doing without posting miles of code. Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Leaders snarfblam Posted September 18, 2006 Leaders Posted September 18, 2006 Have you tried multithreading? Or at least a call to Application.DoEvents() when you want to update? By the way, I don't know if this can be done with a batch file, but instead of starting your process and then later finding it by name, can't you just hold on to the Process object returned by Process.Start? Quote [sIGPIC]e[/sIGPIC]
MTSkull Posted September 19, 2006 Author Posted September 19, 2006 Wow application do events really cleaned up a lot of problems. Thanks I also tested the process.start object return and that really cleans up the code as well. I was using the batch file to catch the error level when the program finished, but I can capture the same data with the ExitCode value straight from the process object. Thanks Again MT Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.