Windows Phone . deploy . current . dispatcher.BeginInvoke影响过

本文关键字:BeginInvoke 影响 dispatcher current Phone deploy Windows | 更新日期: 2023-09-27 18:02:49

我正在开发一个windows phone聊天应用程序。我使用Deployment.Current.Dispatcher.BeginInvoke方法更新UI,但在使用Dispatcher.BeginInvoke时屏幕会被击中。如何解决这个问题或任何方法来更新UI而不卡住?

Windows Phone . deploy . current . dispatcher.BeginInvoke影响过

如果您使用分派器,那么您将在UI线程中执行给定的代码。当你在UI线程中执行代码时,UI被卡住了。这是没有办法的,所以你必须确保在UI线程中只执行绝对最小数量的代码。常见的模式是在后台线程中检索/计算数据,然后切换到UI只更新控件。BackgroundWorker类是达到这个结果的一个方便的助手。