开发者

Silverlight UI changes freezes the application

开发者 https://www.devze.com 2023-03-17 03:29 出处:网络
I have a SL application, and I have some events that once the user clicks, the app is doing some work.

I have a SL application, and I have some events that once the user clicks, the app is doing some work. This work freezes the UI until the job is done (the job modifies the UI elements). How can I improve the performance of UI job in the SL app? I read that the UI threa开发者_如何学运维d is the only option.

Thank you


You should use a BackgroundWorker to do your intensive work.

BackgroundWorker on MSDN

It's got an event (RunWorkerCompleted) that's executed on the main/UI thread after the work is completed.

Edit:

If your background job needs to update UI, you can use the Dispatcher:

Dispatcher.BeginInvoke on MSDN

Example:

Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show("This is executed on UI thread"));
0

精彩评论

暂无评论...
验证码 换一张
取 消