Display animated gif while running sub

How to save animated gif while my application is working under. The entire user interface is locked, so I tried to display it in a different form, but I get the same result.

+4
source share
2 answers

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 
+5
source

You should take a look at

The BackgroundWorker class allows you to start operations on a separate, dedicated thread. Painstaking operations such as loading and a transaction database can cause the user interface (UI) to look as if it has stopped responding while they are running. When you need a responsive interface and are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

+2
source

Source: https://habr.com/ru/post/1301106/


All Articles