Console App and DoEvents

Microsoft Visual Studio .NET

DoEvents is part of the Forms class.  Is there a comparable method within 
Console Apps that gives control up to the OS the same way DoEvents does?

Yes, you're right. DoEvents is part of the Windows Form applications, which 
allows a WinForm application to process other Windows messages currently in 
the message queue while it is executing a method that handles one Windows 

As we all know, a Console application doesn't have the mechanism of message 
loop, so there's no counterpart of DoEvents in Console applications.

Hope I have made some clarifications.
If you have any concerns, please feel free to let me know.

Linda Liu
Microsoft Online Community Support

Get notification to my posts through email? Please refer to
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at
This posting is provided "AS IS" with no warranties, and confers no rights.
I understand your reply.  What I'm looking for is a way to force my "app" to 
give up control to the OS to process.  I understand how preemptive 
multitasking works where the OS just suspends your process to allow other 
processes time to do work.  I've written VB3/5 code in the past that does a 
LOT of work in a tight loop causing other processes to suffer (client and 
server-side applications).  The DoEvents, even when used in VB6 "batch" apps 
often had a hidden form and I used "DoEvents" within these CPU intensive 
loops to give up control to Windows to catch up.

Is there something, short of bringing in the Forms class to do for Console 
apps what DoEvents did in the past.

Assume I have 3 console apps that are not set up as services running on a 
server and each does a different task, and each could hog the CPU when it 
gets control, and I'm trying to allow for a round-robin effect where each of 
the 3 EXE's gets time while one or more of the apps is working on a long task 
(say 20 CPU sucking minutes).  How can I force each app to come up for air 
after processing "x" items?  Or is Windows going to preempt me anyway doing 
what I want, just not neccessarily when I want it.. 

Hi Doug,

Thank you for your prompt response. I understand what you really want now.

You may call the System.Threading.Thread.Sleep method to block your program 
for specified number of milliseconds, which will allows other processes to 

For more information on the Sleep method, you may visit the following link.

'Thread.Sleep Method (Int32) '

Hope this helps.
If you have any question, please feel free to let me know.

Linda Liu
Microsoft Online Community Support