-
August 9th, 2001, 02:44 AM
#1
CPU hungry functions & the message pump. Problem with WM_CLOSE.
In my application I some fucntions that wait for data from a data aquistion card. They therefore block the thread. In order to aleviate the problem I have used a message pump.
MSG message;
while(::PeekMessage(&message,NULL,0,0,PM_REMOVE))
{
::TranslateMessage(&message);
:ispatchMessage(&message);
}
However I have found a strange thing occurs if I attempt to close the application whilst it is in this state. The Window for the App disappears as if the application has exited but the application continues to fuction continuing merrly to make more measurements etc. Is there anyway that I can ensure the shutdown of th app on WM_CLOSE?
Simon Pettman.
-
August 9th, 2001, 10:29 AM
#2
Re: CPU hungry functions & the message pump. Problem with WM_CLOSE.
You should check for WM_QUIT message in the loop:
MSG message;
while (::PeekMessage(&message,NULL,0,0,PM_REMOVE))
{
if (message.message == WM_QUIT)
{
// repost WM_QUIT message so the main message loop will see it
// and terminate properly
PostQuitMessage(message.wParam);
// do necessary cleanup and return
return;
}
::TranslateMessage(&message);
:ispatchMessage(&message);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|