WPF - Dispatcher PushFrame()
- by Tri Q
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?