How CWinThread::OnIdle is used?

As you know, OnIdle can be specified in MFC UI thread. For details, you can read this reference But I am not sure how it can be used in practice.

According to the reference above,

"OnIdle is called in the default message loop when the thread's message queue is empty. Use your override to call your own background idle-handler tasks."

So I can understand that when the UI thread is not busy, the method is called. According to the documentation above,

"Because the application cannot process messages until OnIdle returns, do not perform lengthy tasks in this function."

But what tasks can be done in the idle event? A single example would suffice. Thanks

UPDATE: One discouraging fact is that this old (1996) article is very helpful to understand CWinThread.


MFC uses its default OnIdle processing to enable and disable menu items and toolbar buttons, as you can see in the documentation for CWinApp::OnIdle. There doesn't have to be explicit code to enable or disable these items as conditions change, it just happens automatically when nothing else is going on.

Windows itself uses a similar strategy for firing WM_PAINT messages - those only get generated when nothing else is in the message queue.

You use this technique when you have a low-priority task you want to do.

Need Your Help

What is the difference b/w Bash and Shell script

linux bash shell cmd scripting

I've been writing scripts for both UNIX and Windows for almost 3 years now. I've always been confused about these two terms, for a while I thought that bash scripts were windows cmd scripts and shell

how does this ie check work?


I've seen this method of detecting IE in several online examples:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.