Note that there are some explanatory texts on larger screens.

plurals
  1. PODispatcher didn't update label
    text
    copied!<p>I have a ListBox which I put some files, if the file is not AVI I automatically converts it but I want when the files converting message will write on a label that the files are now converted to another format, what happens to me now is only when the program has finished converting them its update the label and not in the process</p> <p>after all the fixes:</p> <pre><code>private void btnAdd_Click(object sender, RoutedEventArgs e) { btnPlay.IsEnabled = false; Stream checkStream = null; Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Multiselect = true; openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "All files (*.*)|*.*"; openFileDialog.FilterIndex = 1; openFileDialog.Title = "Please Select Source File"; if ((bool)openFileDialog.ShowDialog()) { if ((checkStream = openFileDialog.OpenFile()) != null) { foreach (string file in openFileDialog.FileNames) { try { FileInfo fileInfo = new FileInfo(file); listBoxFiles.Items.Add(file); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } for (int i = 0; i &lt; listBoxFiles.Items.Count; i++) { string path = (string)listBoxFiles.Items[i]; FileInfo fileInfo = new FileInfo(path); if (fileInfo.Extension != ".AVI") { listToRemove.Add(path); } } (new System.Threading.Thread(ProcessAviFiles)).Start(); foreach (string file in listToRemove) //remove all non .AVI files from listbox { listBoxFiles.Items.Remove(file); } } } else { } if (listBoxFiles.Items.Count != 0) { btnClear.IsEnabled = true; btnPlay.IsEnabled = true; } listToRemove.RemoveRange(0, listToRemove.Count); } </code></pre> <p>function:</p> <pre><code>public void ProcessAviFiles() { if (listToRemove.Count == 0) { return; } 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 EditCap(fileInfo); String newFileName = editpcap._newFileName; Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =&gt; { listBoxFiles.Items.Add(editpcap._newFileName); })); } lblStatus2.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action( () =&gt; { lblStatus2.Content = "Select adapter and packet file, Click play button to start."; btnClear.IsEnabled = true; })); } </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