Forcing MFC to read message queue 
Author Message
 Forcing MFC to read message queue

Hi

I have a method within CDaoRecordView that loops through a database
and does processing on records. This loop sometimes runs for over 5
minutes and during this time the application seemingly does not
process windows messages.

Is there a command that I can put somewhere in the loop that will
force it to read and process messages before contiueing?

I have found the RunModalLoop command in the documentation but I am
not sure how to use this command(s) or if it will even solve my
problem.

Please help

Robert McLaren



Sat, 30 Dec 2000 03:00:00 GMT  
 Forcing MFC to read message queue
Use a background thread. See AfxBeginThread()
Quote:

> Hi

> I have a method within CDaoRecordView that loops through a database
> and does processing on records. This loop sometimes runs for over 5
> minutes and during this time the application seemingly does not
> process windows messages.

> Is there a command that I can put somewhere in the loop that will
> force it to read and process messages before contiueing?

> I have found the RunModalLoop command in the documentation but I am
> not sure how to use this command(s) or if it will even solve my
> problem.

> Please help

> Robert McLaren



Sat, 30 Dec 2000 03:00:00 GMT  
 Forcing MFC to read message queue

Quote:

> Hi

> I have a method within CDaoRecordView that loops through a database
> and does processing on records. This loop sometimes runs for over 5
> minutes and during this time the application seemingly does not
> process windows messages.

> Is there a command that I can put somewhere in the loop that will
> force it to read and process messages before contiueing?

> I have found the RunModalLoop command in the documentation but I am
> not sure how to use this command(s) or if it will even solve my
> problem.

> Please help

> Robert McLaren

Try calling this within your loop.  If it returns FALSE abort your loop,
the program is closing.

BOOL KeepPumpingMessages()
{   MSG msg;
    while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
    {   if ( !AfxGetApp()->PumpMessage() )
        {   ::PostQuitMessage(0);
            return FALSE;
        }
    }
    // let MFC do its idle processing too
    LONG lIdle = 0;
    while ( AfxGetApp()->OnIdle(lIdle++ ) )
        ;  // null statement
    return TRUE;

- Show quoted text -

Quote:
}



Sun, 31 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Reading legacy Message Queue messages

2. Q: Force message queues to be processed during while loop

3. read in a flat file and write in a message queue

4. Non-blocking reading of message queue

5. Exceeding the number of posted messages per message Queue under Win2K

6. Customized Messaging to Message Queue

7. how to clean the message queue from timer-messages

8. Sending a message to the system message queue

9. What happens to WM_TIMER Messages if the message queue isn't empty

10. How many messages are waiting in a message queue

11. how many messages are awaiting in a message queue

12. message queue and message processing

 

 
Powered by phpBB® Forum Software