Grabbing messages while busy
-
Hi all, my app has a very time consuming function where all files on the computer are ennumerated, and ibe put a "cancel" button on the dialog so the user can cancel the ongoing operation, but (of course) the app doesnt process its messages while the ennumeration is running, so it never sees the user pressing the cancel button. I know im supposed to implement some code inside the time consuming function so the app has a chance to get and process its messages, but i dont know exacly what functions to call. BTW, the app is a WTL - dialog based app (not MFC). Any help would be much appreciated.
-
Hi all, my app has a very time consuming function where all files on the computer are ennumerated, and ibe put a "cancel" button on the dialog so the user can cancel the ongoing operation, but (of course) the app doesnt process its messages while the ennumeration is running, so it never sees the user pressing the cancel button. I know im supposed to implement some code inside the time consuming function so the app has a chance to get and process its messages, but i dont know exacly what functions to call. BTW, the app is a WTL - dialog based app (not MFC). Any help would be much appreciated.
Ernesto D. wrote: I know im supposed to implement some code inside the time consuming function so the app has a chance to get and process its messages, but i dont know exacly what functions to call. You're supposed to do the work in a worker thread, which will leave your UI thread responsive. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Ernesto D. wrote: I know im supposed to implement some code inside the time consuming function so the app has a chance to get and process its messages, but i dont know exacly what functions to call. You're supposed to do the work in a worker thread, which will leave your UI thread responsive. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Hi all, my app has a very time consuming function where all files on the computer are ennumerated, and ibe put a "cancel" button on the dialog so the user can cancel the ongoing operation, but (of course) the app doesnt process its messages while the ennumeration is running, so it never sees the user pressing the cancel button. I know im supposed to implement some code inside the time consuming function so the app has a chance to get and process its messages, but i dont know exacly what functions to call. BTW, the app is a WTL - dialog based app (not MFC). Any help would be much appreciated.
Thanks for your answers, i was hoping to avoid multple treads, since the app is just a very "basic" utility that searches for certain files, but if its the only way to go then, so be it. why would it be considered "bad" to use PeakMessage() etc.? thanks.
-
Thanks for your answers, i was hoping to avoid multple treads, since the app is just a very "basic" utility that searches for certain files, but if its the only way to go then, so be it. why would it be considered "bad" to use PeakMessage() etc.? thanks.
Try this in your while loop..
if(GetMessage(&msg,NULL,0,0)) { DispatchMessage(&msg); if(msg.wParam==WM_DESTROY) { PostQuitMessage(0); return; } }
greatest thing is to do wot others think you cant :)
suhredayan@omniquad.com -
Multithreading isn't something you just flip a switch and now your application is multithreaded. If you haven't laid the groundwork for resource locking, it would be a VERY bad idea to try to make an application multithreaded when a message pump is such a simple and functional alternative. Tim Smith I'm going to patent thought. I have yet to see any prior art.