询问者
wpf 如何在异步线程中始终保持对textbox的访问

问题
全部回复
-
我在后台线程中声明了异步操作 await Dispatcher.begininvoke((Action)(()=>textcheck())), 此线程在整个应用程序生命周期内始终运行,用于定时地检测textbox.text的文本内容,但一旦该线程启动,程序就失去响应。如何既让UI界面保持响应,又可以让后台线程始终运行,并保持对UI控件的访问。
- 已合并 Hart WangModerator 2017年5月15日 6:21 duplicate
-
Hi,
根据你的描述,问题应该是你在GUI线程使用了这个await这个等待操作,导致GUI线程(主线程)在等待,所以UI没有响应接下来的操作。
我建议你应该再开启一个线程,再这个线程中检测textbox的文本内容。
我为你找到一个demo,其他线程和主线程(UI)交互的实例,你可以看一下,它如何线程之间的协作。
如果你的问题解决了,请及时标记有用的回复作为答案,这样会帮助遇到相同问题的人。
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Hi,
根据论坛规则,我们不能重复发帖。
我将会合并这些帖子。
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Hi,
WPF的问题,你可以去这个论坛发帖,
https://social.msdn.microsoft.com/Forums/zh-CN/home?forum=wpfzhchs
Best Regards,
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.