Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 





when to use DoEvents in vb.net? (Tuesday, January 03, 2006)



Found the following interesting discussion in the Newsgroups:

when to use DoEvents in vb.net?
by: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


 Reply:
by:Alex Papadimoulis

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

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.

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?
--
Alex Papadimoulis


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
There is no 'DoEvents' necessary if you put the dataset processing stuff
into a separate thread.
--
Herfried K. Wagner [MVP]


 Reply:
by: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.




Posted by Xander Zelders



1 Comments:

Anonymous Anonymous said...

Putting the dataset processing in another thread would prevent the main thread from freezing until the process is done. But you have to realize with large processes the thread will run your cpu at 100% until done, without doevents.

9:28 AM  

Post a Comment

<< Home

 
Previous Posts
    - Playing Audio from a Filestream using MCI
    - XML in a combobox
    - Setup Project
    - WMI Com Interop exception handling
    - Problem With Mailto Start Process
    - Comboboxes in windows forms datagrid
    - Sometimes I want to skip a page - How to do that
    - FxCop Error on command button
    - How to scroll down on listView (programmatically)
    - Open a file save as byte



Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland