doevents

  • Thread starter Thread starter shawrie
  • Start date Start date
S

shawrie

hi can someone help me out please. I have a form that imports data into
sql.
On click of a button it assigns some text to a label. Nothing appears
in the label though. I have found that the labels get populated when i
issue a doevents

can anyone shed any light on this?

thanks neil
 
neil,

Calling DoEvents allows the form's message pump to check for new messages
such as repaint.
 
thanks for getting back to me. Surely the label should be populated
straight away? I never came across this problem with eVB
 
I never used eVB so I can't compare, but it's not unusual in Windows apps in
general that you may need to give the message pump an opporunity to run
while you have a long-running loop. Using a worker thread for long-running
processes is often recommended as a way to keep the GUI part of an app
responsive while your app is also busy with other work, but in general I
feel that if DoEvents achieves your goal, then use it.
 
its certainly doing the job . Im new to threading whats worker thread?
do you know any good sites to read up about threading using VB .NET
(compact framework)?

thanks again for your help
 
Look at any documentation for the Thread class. Using multiple threads is
trickier than just using DoEvents and also involves writing more code, so I
don't recommend using multithreading unless you really need to and you know
what you're doing.

An example of where you would need a worker thread is if you want to have a
thread watching for network connectivity of some sort and then updating your
local or remote database while a user continues to work with your app. I
used to use worker threads for listening to serial ports, but the SerialPort
class now manages that internally. Some people also use worker threads for
filling list controls like listboxes and comboboxes with data on app startup
or loading a dataset with data, but I prefer to use SqlCeResultSet with SQL
Mobile data and bind the data to controls such as the DataGrid which only
get the data for visible rows thus avoiding the need to load all the data at
once.

Maarten Struys did a great series of webcasts about multithreading. Here's
one of them:
http://msevents.microsoft.com/cui/W...&EventCategory=5&culture=en-US&CountryCode=US
 
Back
Top