Two things:
- Use
BackgroundWorker (example below) - Rather, use an indefinite progress bar if possible, but it depends on the technology used.
Example for 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
source share