WPF calls not working during long method processing

Posted by Colin Rouse on Stack Overflow See other posts from Stack Overflow or by Colin Rouse
Published on 2010-04-13T16:03:43Z Indexed on 2010/04/13 16:23 UTC
Read the original article Hit count: 319

Filed under:
|
|
|
|

Hi, The following method does not apply the wpf changes (background = red) until the 2nd method (DoWork) exits:

private void change()
{
    Background = Brushes.Red;
    Dispatcher.BeginInvoke((Action) DoWork);
}

DoWork() takes several seconds to run and I don't really want to put it into a thread, as this code will be used in several places and will probably interact will the Dispatcher thread at various intervals. I've tried calling the Invalidate...() methods, but to no avail. The BeginInvoke() was added to see if the delay would allow the background change to be applied before the logic was called. Typically, the logic would be part of this method. Btw, most of the logic is performed on a different thread and shouldn't block the Dispatcher thread?!

Can someone please help? Thanks

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#3.0