DoEvents in C#?

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Just starting C# from a VB background.

Is there a C# keyword comparable to the vb keyword DoEvents?

Tony!
 
push ctrl-alt-j and search for doevents, you will find it is Application.DoEvents()
 
Tony said:
Just starting C# from a VB background.

Is there a C# keyword comparable to the vb keyword DoEvents?

Others have posted about Application.DoEvents() - but most of the time
when you need to call DoEvents, you should actually be thinking of
using a different thread instead.
 
I don't know if that's really true. If you want your app to be doing only one thing but allow the user to cancel it or just to allow
the GUI to update then doevents is quite suitable.
 
Michael Culley said:
I don't know if that's really true. If you want your app to be doing
only one thing but allow the user to cancel it or just to allow the
GUI to update then doevents is quite suitable.

I'm afraid I disagree - you need to work out where to call DoEvents,
make sure you don't have reentrancy problems etc. I believe it's far
cleaner to start a new thread - it will also make your UI itself
perform better for repaint requests etc, as it won't have to wait for
your next call to DoEvents before repainting.
 
Hi Michael,

I totally agree with Jon.
DoEvents was good because there was no multithreading with VB<=6.
You really should use Backgroundthread thread instead.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Michael Culley said:
I don't know if that's really true. If you want your app to be doing only
one thing but allow the user to cancel it or just to allow
the GUI to update then doevents is quite suitable.
 
Michael,

I'm going to throw my hat in with Jon and Miha as well. DoEvents is not
the way to go. As a matter of fact, I find DoEvents to be downright evil,
and even encouraged MS to take DoEvents off the Application class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Michael Culley said:
I don't know if that's really true. If you want your app to be doing only
one thing but allow the user to cancel it or just to allow
the GUI to update then doevents is quite suitable.
 

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

Back
Top