Widescreen WPF User Interface Access for WPF

In C #, I have several workers that work, and I need to reflect this in the user interface. Update the progress bar, add items to the list, etc.

The first time I tried to do this, I prepared everything with locks so that every moment of access to the user interface received only one thread, but I got an exception. So I found out what I need to use Dispatcher.Invoketo access and change user interface elements. It's pretty cumbersome to put every UI change into a call, but I can handle it.

My questions:

  • Do I need to synchronize calls Dispatcher.Invokeor is this done internally? . So I'm wondering if I need to add another layer of protection with locks ...
  • Does this have a performance impact with many update requests queued to the dispatcher? . So if several threads work, and each of them is reflected in the user interface with a slight change, how many Dispatcher calls. Invoke `affects performance? Should I use the timer and update the user interface only once and stop all user interface changes inside?
  • Is there an easier way to make end-to-end access to more inline ... without Invokes?
+4
2

200 /. .

, , , 200 . (5 /), .

, . , . , , .

+7

Dispatcher.Invoke ? , ...

, .

, , ? , , , Dispatcher.Invoke` ? ?

Invoke, BeginInvoke, ( ), , .

. . , .

BeginInvoke , . , , .

inline... Invokes?

  • , async/wait:

    UpdateUI();
    await Task.Run(...);
    UpdateUI();
    
  • Paraller.ForEach, varayable, .

+3

All Articles