doevent

  • Thread starter Thread starter Lal - Luxor
  • Start date Start date
Application.DoEvents

But only if you really need to. DoEvents is a VB thing, and only included in
VB.NET for compatability.

Best Regards,
Phil Harvey
 
Phil,

If that were true then DoEvents would be part of the visual basic
compatibility namespace and the help files would not give an example of using
doevents in C#.

Kerry Moorman
 
Phil,
But only if you really need to. Correct.

DoEvents is a VB thing, and only included in
VB.NET for compatability.
Totally false, DoEvents is a Windows Forms thing! Hence it being part of the
System.Windows.Forms.Application class.

It allows your program to invoke the Windows Forms Message Pump. the Message
Pump is a Win32 feature that allows your app to remain responsive to windows
messages. It converts Win32 messages into Windows Forms events.

Useful when you have an event handler that is taking too much time.
But only if you really need to.
You need to be careful as DoEvents will allow your event handlers to be
reentered, for example if you call it while handling the Button1.Click
event, you could cause a second Button1.Click event to be handled at the
same time (assuming the user pressed button1 twice), this may cause
unexpected or undesired behavior in your app.

Hope this helps
Jay
 
Thanks for that Jay, your right about the compatability and I was mistaken.
I've got this thing about it stuck in my head because I try and use threads
for anything that might hang the UI, and hence need a DoEvents call.
I just don't trust the things. Its probably just my paranoia.

Phil
 
Phil,
Trying to use Threads is normally a good thing. However there are times when
not using them & using a Timer may be better...

It appears that VS.NET 2005 (aka Whidbey, due out later in 2005) will have a
new BackgroundWorker class that will make working with threads for easier.

For details on the System.ComponentModel.BackgroundWorker class see:
http://msdn2.microsoft.com/library/4852et58.aspx

For details on VS.NET 2005 see:
http://lab.msdn.microsoft.com/vs2005/

Hope this helps
Jay
 

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