0

So I'm pulling some stuff from a database via a different thread, and want the form to remain usable while doing so, and also want to show the user a progress indicator until the DB code finishes.

In 'normal' winforms I'd use a ProgressBar with the ProgressBarStyle set to Continuous, but CF doesn't have that. Neither does it seem to support animated GIFs in a PictureBox (which would have been an easy way).

So what are my options for doing something like this?

EDIT: Don't want to use an hourglass mouse cursor because that implies to the user that the UI is busy (it's not).

Thanks

Jez Clark
  • 383
  • 5
  • 19
  • Add a hidden progressbar to the form. Show it when the long running task is started. You need to use another thread or background worker to update the progressbar. This must be done by an Invoke, as the thread can not access the GUI directly. See also https://stackoverflow.com/questions/8309193/c-sharp-progressbar-threading-mobile-6 and possibly http://www.hjgode.de/wp/2010/06/01/mobile-development-easy-to-use-background-thread-with-gui-update/ – josef Feb 02 '18 at 05:34

1 Answers1

0

You could look for a 3rd party progress bar control that supports the Continuous progress bar style, or a control that supports animated gifs - you're not the first running into this limitation, but I'm not sure if there are any good ones out there.

Rolling your own "continuous" progress bar UserControl shouldn't be very hard, you get a decent result with just a timer to call Invalidate, and using Graphics.FillRectangle in the Paint event.

An alternative to an animated gif control could be to create a "film strip" UserControl, where you provide an image (non-gif) that contains all "frames" of the gif layed out horizontally or vertically. Again you'd need a timer to call Invalidate and increase the frame number, and Graphics.DrawImage has an overload to specify which portion of the film strip image is drawn.

Instead of the timer you could use @josef's comment to increment the "current frame" whenever the worker thread has finished a portion of the work. The animated gif's "movement" would then actually show the user that work is being done.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72