由于线程,wpf windows没有响应 [英] wpf windows unresponsive because of threading

查看:88
本文介绍了由于线程,wpf windows没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

wpf windows由于线程无法响应

wpf windows unresponsive because of threading

推荐答案

阅读文档:https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.invoke(v=vs .110).aspx [ ^ ]

Dispatcher.Invoke方法



在与Dispatcher关联的线程上同步执行指定的委托。


因此,如果您在UI线程上执行该代码,则UI将停止响应,直到它退出循环。



尝试使用 SerialPort.DataRecieved [ ^ ]事件并逐个字符地处理数据。
Read the documentation: https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.invoke(v=vs.110).aspx[^]
"Dispatcher.Invoke Method

Executes the specified delegate synchronously on the thread the Dispatcher is associated with."

So if you are executing that code on your UI thread, then the UI will stop responding until it exits the loop.

Try using the SerialPort.DataRecieved[^] event and processing the data character by character instead.


这篇关于由于线程,wpf windows没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆