Windows' "Not Responding" Notification and the OnSize handler

If some process takes too long (about 5 seconds) and the GUI can't refresh, Windows add the words "Not Responding" to the title bar of some or all windows.    Its been hard to figure out what is going on, but it seems this notification causes my MFC application to run the "OnSize" handler for the top most window (I suppose the one that got the "Not Responding" text added).  This is very annoying and was causing my App to crash until I wrote special code to try to determine if a given call to OnSize is legitimate or not -- if not I just return.  Now, at least, it doesn't crash -- but something in this process is taking a lot of time -- my App seems to freeze for a while to try to figure this all out, then resumes again.  Hard to figure out what is going on.  Anyone seen this before?
(btw - I know I should not have long processes in the GUI loop and they should be in a separate thread - and going thru my whole app and making sure that is true is one approach I'm working on, but I think this oddity can occur when some other process on the PC is taking a long time)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi tullhead,

Windows treats an application as not responding if it doesn't handle any pending Windows message (or, more exact, if it doesn't call PeekMessage or GetMessage is called from the main window's GUI thread) for longer than about 5 seconds. In this case the real main window is hidden and a so called ghost-window is created as kind of placeholder which hinders the not repsonding window from 'locking' parts of the desktop. As soon as the application continues handling messages this ghost window is destroyed and the application's top-level-window is restored at its previous position and redrawn exact the same way as if it would have been restored from a previously minimized window. Therefor it's correct to even recieve WM_SIZE messages.

To disable this behavior for your application it shoul be enough to call DisableProcessWindowsGhosting(); when initializing the GUI process - see for more info.

It even seems to be possible to avoid this for any installed program without need to change the code - for more info about this take a look at the lower section at

I hope this helps,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
you can add a timer to your view or dialog's message queue which would call PeekMessage - say - every 100 msec. this should stop windows to show the 'not responding' message. you could use the OnTimer handler for this.

the OnTimer also might be a way to part lengthy processes into shorter pieces without creating a thread. for example if you now have a function which performs a loop with thousands cycles, you could instead call the same function 10 times from OnTimer where each call performs only a range of 100 cycles. you would need some shared object (class) which stores the intermediate results, but probably this method is faster to implement than a true threading solulution.

tullheadAuthor Commented:
Thanks Zoppo - I never knew about that!  Very helpful.   Thanks also to sarabande!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.