Processing messages in a while loop

  • Thread starter Thread starter Jerry S
  • Start date Start date
J

Jerry S

Hi

A beginner's question.

I want to run through a series of instructions over and over until a
user hits a button.

What's the standard way of making the application process user input
whilst it is in a loop like this (i.e., so that it doesn't just get
stuck in the loop forever)?

I seem to remember in Delphi there is something like
Application.ProcessMessages to do this (my memory could be mistaken,
though!). Is there something similar in C#?

Thanks.

Jerry
 
Hi

A beginner's question.

I want to run through a series of instructions over and over
until a user hits a button.

What's the standard way of making the application process user
input whilst it is in a loop like this (i.e., so that it doesn't
just get stuck in the loop forever)?

I seem to remember in Delphi there is something like
Application.ProcessMessages to do this (my memory could be
mistaken, though!). Is there something similar in C#?

Jerry,

Yes. In System.Windows.Forms, check out the Application class. It
has a DoEvents method that is the same as Delphi's
Application.ProcessMessages.

Also, you may want to consider using a separate thread to do the
processing.

http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/toc.asp
(http://tinyurl.com/sb4b)

http://msdn.microsoft.com/library/en-
us/cpguide/html/cpconthreading.asp
(http://tinyurl.com/sb4i)

http://msdn.microsoft.com/library/en-
us/csref/html/vcwlkThreadingTutorial.asp
(http://tinyurl.com/sb4r)


Hope this helps.

Chris.
 
Back
Top