当用户界面中发生繁重的任务时,可以显示繁忙指示器吗?在我们的应用程序中,大部分长时间运行的任务都是渲染控件,我们需要在渲染时显示指标。Silverlight - 在繁忙的用户界面上显示BusyIndicator线程
1
A
回答
0
在UI线程繁忙期间无法显示加载动画,但可以使用适当的文本显示静态通知,如TextBlock
控件。但是,如果在更新TextBlock
控件的文本后立即在UI线程上开始长时间运行操作,则控件的UI将不会更新,直到操作结束。要解决这个问题,您可以使用以下问题的答案中描述的技巧:Showing a text indicator before freezing the Silverlight UI thread。
0
首先,看看使用后台线程做长期工作。如果这是不可能的,即真正花费时间在UI线程上加载UI组件,那么您肯定可以在加载部件顶部放置一个繁忙指示器作为覆盖层,然后在加载所有内容时隐藏覆盖层。
顺便说一下,它很难编写响应式的多线程应用程序,而无需将UI逻辑与UI分离。研究'MVVM'模式。使用MVVM将使您的应用程序突飞猛进。
我想说,没有严重的应用程序使用“后面的代码”,即一切都通过DataContext,数据绑定,ViewModels和Commands完成。
否则,请查看使用任务或BackgroundWorker并理解Dispatcher。
卢克
0
尝试使用DispatcherTimer设置运行任务重调用之前(通过使用延迟)的忙闲指示。
然后,您可以在重任务完成后禁用指示器。
适合我。
'enable busy indicator & set up the timer'
Private Sub renderControl(ByVal sender As Object, ByVal e As RoutedEventArgs)
_busyIndicator.IsBusy = True
Dim timer As New DispatcherTimer
timer.Interval = TimeSpan.FromMilliseconds(100)
AddHandler timer.Tick, AddressOf renderControl_TimerTick
timer.Start()
End Sub
'do your heavy task, disable busy indicator then stop the timer'
Private Sub renderControl_TimerTick(ByVal sender As Object, ByVal e As EventArgs)
DoStuff()
_busyIndicator.IsBusy = False
'Stop the timer'
TryCast(sender, DispatcherTimer).[Stop]()
End Sub
希望这有助于!
相关问题
- 1. Silverlight BusyIndicator
- 2. Silverlight BusyIndicator内容禁用
- 3. WPF BusyIndicator在后台线程上
- 4. Silverlight工具提示BusyIndicator在Silverlight 5上的阴影效果
- 5. BusyIndicator控件不显示
- 6. Silverlight BusyIndicator背景颜色
- 7. 如何在ComboBox中显示BusyIndicator
- 8. 在STA线程上显示繁忙指示器
- 9. Silverlight 4 - 使用DomainDataSource工作的BusyIndicator
- 10. UI冻结而不是显示BusyIndicator控件在Silverlight
- 11. BusyIndicator不工作在silverlight MVVM
- 12. Silverlight BusyIndicator的Ajax风格风格?
- 13. 哪个dll具有Silverlight的'BusyIndicator'?
- 14. BusyIndicator不从异步方法显示
- 15. WPF BusyIndicator控件显示不出来
- 16. BusyIndicator使用MVVM
- 17. 繁忙的等待线程
- 18. Silverlight的Facebook的A样繁忙指示
- 19. 表面绘制线程 - 繁忙循环?
- 20. WPF Toolkit BusyIndicator
- 21. BusyIndicator控件
- 22. BusyIndicator不可见?
- 23. Silverlight WCF - 无效的交叉线程繁忙指标异常
- 24. DependencyProperty不更新BusyIndicator
- 25. 如何在UserControl加载时显示BusyIndicator
- 26. 新手:使用BusyIndicator控件(Silverlight和WCF服务)
- 27. Silverlight - 当ListBox使用BusyIndicator呈现时屏蔽屏幕
- 28. MobileFirst 7.1 BusyIndicator显示奇怪的字符
- 29. 繁忙的指标在漫长的WPF界面绘制操作
- 30. 如何强制BusyIndicator?
检查此http://forums.silverlight.net/post/556179.aspx – 2012-04-19 09:25:43
谢谢,已经检查:) – arcbound08 2012-04-19 10:06:50