MikeDFarrant
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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 = )
ASKER
Thanks for your answer.