当我在线程中使用时一切正常:
richtextbox1.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { this.richtextbox1.AppendText(text); }));
但是当我在线程中使用时,我收到错误"调用线程无法访问此对象,因为其他线程拥有它">:
richtextbox1.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { this.richtextbox1.Document.Blocks.Add(paragraph); }));
如果我尝试使用 richtextbox1,我也会收到此错误。文档 = some_FlowDocument
找不到如何在 WPF 中解决此问题的方法
需要在主线程中创建流文档和段落并调用