简体   繁体   English

如何使用WPF调度程序创建多UI线程Winforms应用程序

[英]how to use the wpf dispatcher to create a multi UI thread winforms app

The second answer by Martin in this link explains how the dispatcher can be used in a winforms app. Martin在此链接中的第二个答案说明了如何在Winforms应用程序中使用调度程序。 This link explains the wpf side. 链接解释了wpf方面。 So my question is - can we do this in a winforms app ? 所以我的问题是-我们可以在winforms应用程序中执行此操作吗? If not, why ? 如果没有,为什么? thank you 谢谢

UPDATE: I have found this link also that shows the multiple app.run method mentioned by Henk below. 更新:我也发现此链接还显示了下面Henk提到的多个app.run方法。 However it does not use the wpf dispatcher. 但是,它不使用wpf调度程序。 I wonder if there is a performance diff between using the wpf dispacther in winforms (my question) vs multiple app.runs 我想知道在winforms中使用wpf dispacther与我的多个app.runs之间是否存在性能差异

No matter what you do, you will be limited to using 1 thread (the UI thread) to update your windows (Winforms, WPF, native code). 无论您做什么,都将只能使用1个线程(UI线程)来更新窗口(Winforms,WPF,本机代码)。 You can spawn as many worker threads as you want to do all the data gathering and prep work you need, however you'll still have to use the UI thread to do the updates. 您可以根据需要生成任意数量的辅助线程,以完成所需的所有数据收集和准备工作,但是您仍然必须使用UI线程进行更新。 Take a look at the Task or the BackgroundWorker classes to do this work. 看一下Task或BackgroundWorker类来完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM