multithreading - WPF MVVM update label text -


My label text is not being properly updated in my 3.5 WPF MVVM app. Working part is very long that you can see the wait mouse pointer. The one I have ever seen is "Parsed" in the label, which is Bante Infotext. Dispatcher and work lines are in the method of command idea?

Code

  Dispatcher.Invoke ((action  SetInfoText, "Start Parsing"); // do Dispatcher.Invoke ((Action & lt; String & gt;) SetInfoText, "Parsed"); Private Zero SetInfoText (string text) {InfoText = text; } Private string_infoite; Public String InfoText {get {return_infoText; } Set {_infoText = value; OnPropertyChanged ("InfoText"); }}    

The only thing I can think of explaining is that you Working on the UI thread will prevent you from reproducing the dispatcher until your work is completed. The work to be passed in the Inoc is placed in the queue, which means that it will be done on idle.

The correct way to fix this is to work on different threads. If you are looking for action, reference:

EDIT: There are several ways to work on the second thread. Read on backgroundwork, Threadpool, Task Perlélé Library, Threads. :) This is a very easy way to work in a background thread:

  System.Threading.ThreadPool.QueueUserWorkItem (state => {Dispatcher.Invoke ((action)  SetInfoText, "Start Parsing"); System Threading Thread.Sleep (5000); // Simulate Work Dispatcher. Invoke ((Action & lt; String & gt;) Set Infot Text, "Parsed" );});    

Comments