WPF - Dispatcher PushFrame()

Posted by Tri Q on Stack Overflow See other posts from Stack Overflow or by Tri Q
Published on 2010-04-19T04:28:25Z Indexed on 2010/04/19 4:33 UTC
Read the original article Hit count: 759

Filed under:
|
|

Hello,

I'm trying to call Dispatcher.PushFrame() from several different thread but encounter an error:

Must create DependencySource on same Thread as the DependencyObject.

Here is a code snippet:

_lockFrame = new DispatcherFrame(true);
Dispatcher.PushFrame(_lockFrame);

When I tried:

Dispatcher.CurrentDispatcher.Invoke(
    DispatcherPriority.Normal,
    new Action(() => _lockFrame = new DispatcherFrame(true));
Dispatcher.PushFrame(_lockFrame);

I get the error:

Objects must be created by the same thread.

What is the approach for pushing multiple frames into the Dispatcher from different threads?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about multithreading