Getting the right WPF dispatcher in a thread.

Posted by Bert on Stack Overflow See other posts from Stack Overflow or by Bert
Published on 2010-03-17T20:25:51Z Indexed on 2010/03/17 20:51 UTC
Read the original article Hit count: 427

Filed under:
|
|

Hi,

In the constructor of an object i need to create a WPF mediaElement object:

m_videoMedia = new MediaElement();

but the class can also be instantiated from a other thread so i need to use

Dispatcher.Invoke(DispatcherPriority.Normal,
    (Action)(() => { m_videoMedia = new MediaElement(); })); 

But how can I get the right dispatcher instance in that constructor :s

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf