我试图从几个不同的线程调用 Dispatcher.PushFrame() 但遇到错误:
必须在与 DependencyObject 相同的线程上创建 DependencySource。
这是一个代码片段:
_lockFrame = new DispatcherFrame(true);
Dispatcher.PushFrame(_lockFrame);
当我尝试时:
Dispatcher.CurrentDispatcher.Invoke(
DispatcherPriority.Normal,
new Action(() => _lockFrame = new DispatcherFrame(true));
Dispatcher.PushFrame(_lockFrame);
我得到错误:
对象必须由同一个线程创建。
将多个帧从不同线程推送到 Dispatcher 的方法是什么?