0

I am currently developing a C# WinForms program which reads data from an excel file and processes it. This process has a duration up to 5 seconds so I want to show a little rotating gif, so that the user knows that the program actually is processing data and not broken.

So I googled a fitting gif and used a picturebox in visual studio 2017. I am using a picturebox and set the Image to the local gif. After that, the property Image shows "System.Drawing.Bitmap".

If I run the program whilst the picturebox is visible, or trigger the visibility whilst not processing data, the gif is animated. During the dataprocessing, the animation is not shown - I do not use any kind of multithreading in this program as it is pretty small.

Any help would be appreciated. Br

d219
  • 2,707
  • 5
  • 31
  • 36
HalbeSuppe
  • 47
  • 5

1 Answers1

1

In case you have a loop inside of youre code add

Application.DoEvents()

inside of the loop

  • Hey, thanks for the input. The problem does not occur if I have a visible picturebox when starting the app, but if the gif picturebox is not visible at first. and is triggered when loading the file itself. The gif is not moving then. Note that it is a pretty simple program, i do not use multithreading for the dataprocessing. – HalbeSuppe Apr 01 '18 at 19:00
  • Ok then you probably have a while loop which processes your data.Then you just have to add : Application.DoEvents() inside of the loop – Driton Gjuraj Apr 01 '18 at 19:17