Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, calling:</p> <pre><code>p.WaitForExit(); </code></pre> <p>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.</p> <p>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:</p> <pre><code>// 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( () =&gt; { Process p = Process.Start(longRunningProcess); p.WaitForExit(); }); // Reenable the UI when the process completes... task.ContinueWith( t =&gt; { EnableUI(); // hide the circular progress bar ShowHideCirProgBar(false); }, TaskScheduler.FromCurrentSynchronizationContext()); </code></pre> <p>Alternatively, you can do the same thing via a BackgroundWorker:</p> <pre><code>BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (s, e) =&gt; { Process p = Process.Start(longRunningProcess); p.WaitForExit(); }; bw.RunWorkerCompleted += (s, e) =&gt; { 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(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload