I have a windows forms dialog, which does something for longer time after clicking a button.
Because this takes while, I want to show an animation on the dialog (an anmiated gif, avi or whatever). How can I achive this. Do i need an own thread for this (I have no experiences with threads)?
Can you provide me a code snippet how to achieve this ?
I have a windows forms dialog , which does something for longer time after
Share
You can show an animated GIF using a normal PictureBox control, and you can find some useful animated GIFs at Ajaxload.
However, if you’re performing the operation on the UI thread, the program will freeze until it finishes.
To prevent this, use a BackgroundWorker, like this:
Add a BackgroundWorker component to your form.
Handle its
DoWorkevent and perform your operation there.Handle the
RunWorkerCompletedevent and hide the PictureBox.When you want to start the operation, show the PictureBox, then call the RunWorkerAsync method.