Visual C# - How to Refresh datagrid, and other items when datagrid is populating.

Greetings Experts,

Ok, I have a datagrid that I populate with network information. But while the data is being gathered for the datagrid, the form seems hung, which of course it is not, it just isn't repainting. Then when the datagrid has everything it needs, bam! everything shows up, and looks great.

This includes a animation of sorts that I've created to show that the program is actually still working (processsing) which does nothing more then cycle through 8 images to show motion....

But when the datagrid is gathering info, nothing refreshes at all.

I have tried starting a "timer" prior to the datagrid call, where in the timer, it has a refresh of the specifc picturebox's that I want to refresh, (ie. picMyPic1.refresh();) but that didn't work to refresh the "animation" while the datagrid was working on gathering the info.

I also tried just doing a refresh(); on a timer, to just refresh the whole form, again, no dice.

I've also tried putting refresh events into the animation itself (which is on a timer that cycles through the 8 images), but again, no dice...

So, the Q is... how do I activly refresh the screen so that it doesn't look like my app is hung while my datagrid is searching and building it's data.

Thanks!
MiShepsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rpkhareCommented:
Start animation using a different thread. You need to use the concept of Threading here. The problem is happening because the DataGrid and the Animation are using the same thread.

After the line where you fill the DataGrid, use:
Application.DoEvents();

0
MiShepsAuthor Commented:
I was guessing that I would have to start the animation in another thread, but was hoping it would be something easier. I tried the DoEvents(); but it didn't work.

Do you have an example of how I could start the animation in a second thread?

Thanks.
0
rpkhareCommented:
Well, I don't have idea on how it will work on the same Form. Probably opening another Form with animation is good. If you open a small popup Form with the animation, then that can solved the problem. For this see the following link:

http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_CSharp/Q_23582542.html
0
rpkhareCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.