Reputation: 153
I'm building a Windows Form application that manipulates a text file, the manipulation process takes time, so I creadted a Hidden PictureBox Control and I put an animated gif Image in it (Like a Progress Bar), and once the process starts I show the PictureBox, but the gif doesn't move cause it is on the same process I guess, is there any kind of solution...
Thanks
Upvotes: 2
Views: 2700
Reputation: 21471
You should be doing your long processing in another thread, or simply by using a Background Worker.
msdn: http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
Plus, you can report any progress made to a progress bar... Here's an example of use http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx
Note that one of the main reasons why your GUI won't update when you're doing heavy computing, is the fact that the computing is done on the same thread as the UI in running on.
Upvotes: 2
Reputation: 697
One solution is to use Threads, you fired tle process in one thread, then you show the Image... Here you have an excelent guide for beginners in Threads, Beginners Guide to Threading.
But onther easy solution, is to show the picturebox before the process start, so the picture shows in your form before the process take the control of the main Thread.
Upvotes: 1