Application.Doevents hanging

  • Thread starter Thread starter John H
  • Start date Start date
J

John H

I am calling Application.DoEvents in my timer event after doing some
processing. I am finding that the app is hanging on the
Application.DoEvents call in some scenarios. Does not happen
everytime I repeat the steps in the app. I can comment out the
DoEvents call and then I will not get the hanging problem. Problem
then is that the app will not respond to user input. Has any one else
send this behavior on CF apps.
 
Hi,

Are you in a loop inside the timer event? I haven't seen any hangs, in this
scenario (are you sure it is hanging on DoEvents, and not something else in
the loop?) -- but there is no other reason to use DoEvents, IMO. Perhaps,
as Chris says, using a thread to do your processing is the answer. You can
either use the Timer event to create a thread (make sure that it exits in a
"timely fashion"), or use the .Threading.Timer class.

BTW, does the loop that is in the Timer event take longer to execute than
the Timer interval? If so, you may need to consider your design.

Dick
--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 
Back
Top