Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

"Beer is proof that God loves us and wants us to be happy."

-Benjamin Franklin

  • Leaders
Posted

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?

[sIGPIC]e[/sIGPIC]
Posted

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

"Beer is proof that God loves us and wants us to be happy."

-Benjamin Franklin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...