when to use DoEvents in vb.net?

R

Rich

As I migrate my VB6 apps to vb.net I am checking what
features I need to retain from vb6. In vb6 I noticed that
DoEvents really made a performance difference when I
called it just before a Do/For loop for large datasets. I
hope do some multithreading in vb.net for this. But I am
not completely sure about how

System.Windows.Forms.Application.DoEvents()

works, or its application/purpose. Is this the same as
the DoEvents from vb6? Should I keep this feature in my
vb.net projects?

TIA,
Rich
 
A

Alex Papadimoulis

I can't say it any better than the documentation ;-)

"If you call DoEvents in your code, your application can handle the other
events. For example, if you have a form that adds data to a ListBox and add
DoEvents to your code, your form repaints when another window is dragged
over it. If you remove DoEvents from your code, your form will not repaint
until the click event handler of the button is finished executing.

"Typically, you use this method in a loop to process messages.


So the answer is, it depends. Do you want messages to be processed (such as
redrawing)? Or do you want to go for maximum performance and not do it?
 
H

Herfried K. Wagner [MVP]

* "Rich said:
As I migrate my VB6 apps to vb.net I am checking what
features I need to retain from vb6. In vb6 I noticed that
DoEvents really made a performance difference when I
called it just before a Do/For loop for large datasets. I
hope do some multithreading in vb.net for this. But I am
not completely sure about how

System.Windows.Forms.Application.DoEvents()

works, or its application/purpose. Is this the same as
the DoEvents from vb6? Should I keep this feature in my
vb.net projects?

There is no 'DoEvents' necessary if you put the dataset processing stuff
into a separate thread.
 
R

Rich

Thanks all for your replies. It sounds like

System.Windows.Forms.Application.DoEvents()

is the same as DoEvents from vb6. Just wanted to make
sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top