Link to home
Start Free TrialLog in
Avatar of MikeDFarrant
MikeDFarrantFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Multi-thread to pupulate data in Vb.net

How can I call a sub from a Timer but process that sub on a new thread?

I need to refresh screen display from a database every second but I want to still be able to drag the form or perform right click etc. on the form without it appearing to be jerky or slow.

The sub that I want to call every reads the database and populates labels and a datagridview on the main page.  Currently ths sub is being called from a Timer as a standard call, can this simply be swapped to be a mulit-thread.

I am aware that the labels etc. can only be updated in the original thread what about a datagridview that has been linked to a datatable?

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MikeDFarrant

ASKER

I did try background worker before with not a lot of success.  I will take a little deeper look via this link it may take a few days for me to get back to you whether I have been successful (I have a number of prority projects on the boil at the moment!!)  Isn't life wonderful!!

Thanks for your answer.
Thanks for your answer.  The Background worker was much easier than trying to setup a thread.

One thing to note is that one of my controls was a bound data-grid that was supposed to update as a result of the background process.  I could not get this to work...

I could have unbound the grid and populated manually I guess, but as I wanted to change the color of the row based upon a value in the table anyway, I thought I'd just create a control for each row, color it and place it onto a double-buffered panel... it works a treat.

Thanks, for your help.
Glad you got it sorted out  = )