Unfortunately, calling:
p.WaitForExit();
Will cause your program execution to block until the spawned executable exits. This will prevent WPF from processing its message pump, which in turn will prevent your progress bar from updating properly.
The normal way to handle this is to disable your UI elements, then spawn the process in a background thread, showing your progress. When the process completes, re-enable the UI elements. Using .NET 4, this could be something like:
// Add code to disable UI, if required
DisableUI();
// Show the circular progress bar;
ShowHideCirProgBar(true);
// Wait till the process ends execution in a background thread
var task = Task.Factory.StartNew( () =>
{
Process p = Process.Start(longRunningProcess);
p.WaitForExit();
});
// Reenable the UI when the process completes...
task.ContinueWith( t =>
{
EnableUI();
// hide the circular progress bar
ShowHideCirProgBar(false);
}, TaskScheduler.FromCurrentSynchronizationContext());
Alternatively, you can do the same thing via a BackgroundWorker:
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += (s, e) =>
{
Process p = Process.Start(longRunningProcess);
p.WaitForExit();
};
bw.RunWorkerCompleted += (s, e) =>
{
EnableUI();
// hide the circular progress bar
ShowHideCirProgBar(false);
};
// Add code to disable UI, if required
DisableUI();
// Show the circular progress bar;
ShowHideCirProgBar(true);
bw.RunWorkerAsync();