Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The label is not updating because the main UI thread is busy doing other things. </p> <p>Looking to your code, it seems that you are running the AVI file conversion business inside your main UI thread. You should run this time consuming task in a separate thread to make sure your UI stays responsive. </p> <p>Below is a fix to your problem, replace your <code>foreach (String file in listToRemove){}</code> by:</p> <pre><code>Action aviConversion = new Action(() =&gt; { if(listToRemove.Count == 0) return; // nothing to do lblStatus2.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { lblStatus2.Content = "Convert file to .AVI...";}); ); foreach (String file in listToRemove){ FileInfo fileInfo = new FileInfo(file); editpcap = new (classes who convert the files)(fileInfo); String newFileName = editpcap._newFileName; Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { listBoxFiles.Items.Add(newFileName); })); } lblStatus2.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { lblStatus2.Content = "AVI file conversion finished...";}); }); // Run this action in a separate thread... Task.Factory.StartNew(action, "beta"); </code></pre> <p><strong>EDIT</strong> Using <code>Thread</code> instead of <code>Task</code> (OP can't use <code>Task</code>)</p> <pre><code>private void ProcessAviFiles(){ if(listToRemove.Count == 0) return; // nothing to do lblStatus2.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { lblStatus2.Content = "Convert file to .AVI...";}); ); foreach (String file in listToRemove){ FileInfo fileInfo = new FileInfo(file); editpcap = new (classes who convert the files)(fileInfo); String newFileName = editpcap._newFileName; Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { listBoxFiles.Items.Add(newFileName); })); } lblStatus2.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { lblStatus2.Content = "AVI file conversion finished...";}); } </code></pre> <p>replace your <code>foreach (String file in listToRemove){}</code> by:</p> <pre><code>(new System.Threading.Thread(ProcessAviFiles)).Start(); </code></pre>
 

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