SV: Clear pending events
Maximilian Matthé
Maxi.Matthe at web.de
Mon Oct 22 05:25:32 PDT 2007
Hi!
Thanks for your answer. But the problem seems to be deeper in the code.
The message queue seems to be empty. Heres how I send the events from
the threads:
wxCommandEvent ev(wxEVT_UPDATEPROGDLG, wxID_ANY);
ev.SetInt(1);
m_CmpHandler.AddPendingEvent(ev);
m_CmpHandler is a reference to a class derived from wxEvtHandler.
void cModuleData::CompareHandler::OnUpdateProgDlg(wxCommandEvent &e)
{
m_Counter += e.GetInt();
if(wxIsMainThread())
{
if(e.GetInt())
m_ProgDlg.Update(m_Counter);
}
}
m_ProgDlg ist a reference to a progress dialog object. the command event
contains how far the progress has gone since the last event.
I have two threads that send each about 1000 events in about 2 minutes,
i think this is not too much.
As aid, the message loop is empty after I call while(app->Pending())
ap->Dispatch(); But, wxLogError("xyz"); does not appear until the
program ends. What could be the problem too? I have no idea...
Regards, Max
Arne Steinarson schrieb:
> Hello,
>
> There is a function wxApp::ProcessPendingEvents that I
> think does what you want.
>
> Looking into doc for wx I cannot find it there, but
> it's in the headers (for 2.8.4 at least).
>
> Regards
> // ATS
>
>
> --- Maximilian Matthé <Maxi.Matthe at web.de> skrev:
>
>> Hello!
>>
>> I have the following problem: I have a heavy
>> calculation that is split
>> into two threads. Both threads add pending events to
>> an event handler
>> class that updates a progress dialog. So I can show
>> the progress of the
>> calculation.
>>
>> Both threads are joinable, I create them via new in
>> a function, wait for
>> them and delete the threads. The handler is created
>> as a stack variable
>> just in that function. So, when the threads are
>> done, the handler is
>> destructed automatically. But it seems, that there
>> are pending events in
>> the event loop of the application which can only be
>> handled by the stack
>> event handler (its a user defined event type). Thus
>> the message queue is
>> blocked by those events, and e.g. wxLogError does
>> not show messageboxes
>> but waits until the end of the program.
>>
>> So my question is: How can i clear the messageloop
>> from those pending
>> events? I tried this: while(app->Pending())
>> app->Dispatch(); but this
>> had no effect.
>> I dont want to create the handler with new, becuase
>> i only need it in
>> this function, and nobody could delete it
>> afterwards.
>>
>> I hope you can help
>> Max
>>
>>
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> wx-users-unsubscribe at lists.wxwidgets.org
>> For additional commands, e-mail:
>> wx-users-help at lists.wxwidgets.org
>>
>>
>
>
> - - -
>
>
> ___________________________________________________
> Sök efter kärleken!
> Hitta din tvillingsjäl på Yahoo! Dejting: http://se.meetic.yahoo.net
More information about the wx-users
mailing list