当我的应用运行子应用程序时,如何保持动画gif运行。 整个用户界面被阻止,所以我尝试以另一种形式显示它,但我得到了相同的结果。
答案 0 :(得分:5)
两件事:
BackgroundWorker
(以下示例)BG Worker的例子:
Private wrkDeploy As New BackgroundWorker()
Private Sub wndMain_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
AddHandler wrkDeploy.DoWork, AddressOf wrk_DoWork
AddHandler wrkDeploy.RunWorkerCompleted, AddressOf wrk_RunWorkerCompleted
End Sub
Private Sub wrk_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
' Hide Gif and start normal UI process again
End Sub
Private Sub wrk_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
' Do all heavy work here
End Sub
Private Sub btnFilter_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
' Show GIF and disable whatever you need to
wrkDeploy.RunWorkerAsync()
End Sub
答案 1 :(得分:2)
你应该看看
BackgroundWorker类允许您 在一个单独的, 专用线程。耗时的 下载和数据库等操作 交易可能会导致您的用户 界面(UI)看起来好像它 他们已经停止了回应 运行。当您需要响应式UI时 你面临着长时间的拖延 与此类操作相关联的 BackgroundWorker类提供了一个 方便的解决方案。