Pump Messages

13 views
Skip to first unread message

Сергей Коныгин

unread,
Jul 1, 2022, 6:42:08 AM7/1/22
to wx-users
Hi!

I have a code that requires very long time. Every iteration I do "pump messages" (for Cancel button). But this code doesn't work on Linux. Can I do it by wxWidgets?

// piece of code
for( int i=0; i<10000; i++ )
{
    // doing something
    DoCalc();
    // pump messages in Windows
    MSG msg;
    while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ))
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
   // check for cancel button
   if( mbCancel ) break;
}

Vadim Zeitlin

unread,
Jul 1, 2022, 9:22:29 AM7/1/22
to wx-u...@googlegroups.com
On Fri, 1 Jul 2022 03:42:08 -0700 (PDT) Сергей Коныгин wrote:

СК> I have a code that requires very long time. Every iteration I do "pump
СК> messages" (for Cancel button). But this code doesn't work on Linux. Can I
СК> do it by wxWidgets?

Yes, see wxEventLoop class or use wxYield(). But you really shouldn't,
it's a very bad idea to do it like this, so you should rather use porting
to Linux as an opportunity to rewrite your code in a better way.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages