Click to See Complete Forum and Search --> : How do I allow user access to a window while it is doing lengthy work?


September 8th, 1999, 04:16 AM
here's my situation...

i have a popup dlg with a listbox. the list box has tons of items being added to it upon the creation of the popup dlg. it is very lengthy and all messages are halted until the listbox is fully updated.
i like to give the user the ability to do stuff, like close the popup dlg if he/she so desires. here is my code...

while (very_long_update)
{
if ((PeekMessage(&lpMsg, NULL, 0, 0, PM_REMOVE)) > 0)
DispatchMessage(&lpMsg);

//do something lengthy...
}

this seems to work for all messages except when the user closes the popup dlg. (ex. the user can move the dlg around, minimize it, etc. while the listbox is updating...) but when the user closes it (clicking on the X), the dlg dissapears but the thread is still running! i know this for a fact because the VC++ debugger's output doesn't say that the thread has exited with 0x2 code or something like that. In fact when i close the dlg that originally called the lengthy popup dlg (my main dlg), the debugger doesn't end until i have to force it to end by clicking the "Stop Debugging" button (Shift F5).
is there more to processing a QUIT message than what i am doing? or is there another way to do what i want with out peeking into messages? i tried using threads, but it is very unstable since i have to update the popup dlg everytime an item gets inserted into the listbox.

thanks in advance...

James Spibey
September 8th, 1999, 05:48 AM
It would probably be better to fill your listbox using another thread, that way your dialog can process its messages without being obstructed.