Update This?

MTSkull

Centurion
Joined
Mar 25, 2003
Messages
151
Location
Boulder, Colorado
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


C#:
//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.
 
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?
 
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
 
Back
Top