kevin

kevin

  • NA
  • 3
  • 0

progress bar troubles

Aug 20 2007 3:09 PM

hi all,

trying to a write a small app to learn more about c#. was hope to make a simple app to display a progress bar while i started and ran a process in the background (defrag). problem i run into is waiting for the process to end. what eve i try to use to suspend the thread (thread.sleep or WaitForExit()) either one causes the progress bar to stop. is there a way around this?

code is pretty simple, go the progress bar code here (http://www.codeproject.com/cs/miscctrl/C_NeverEndingPBar.asp)

 

private void btnAccept_Click(object sender, EventArgs e)

{

osProgress1.Visible = true;

osProgress1.AutoProgress = true;

}

private void StartDefrag()

{

ProcessStartInfo psi = new ProcessStartInfo("Defrag.exe", "-c -f");

psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

System.Diagnostics.Process listFiles;

listFiles = System.Diagnostics.Process.Start(psi);

listFiles.WaitForExit();

 as soon as it launchs defrag and starts waiting it causes the progress bar to hang. any thoughts?

 

thanks in advance!


Answers (2)