tags:

views:

45

answers:

2

I want to send synchronous event from a worker thread to the UI Main thread. How do I do it in wxWidgets? A link to a sample would be really helpful

A: 

AddPendingEvent - This function posts an event to be processed later. http://docs.wxwidgets.org/2.8/wx_wxevthandler.html#wxevthandleraddpendingevent

ProcessEvent - Processes an event, searching event tables and calling zero or more suitable event handler function(s). http://docs.wxwidgets.org/2.8/wx_wxevthandler.html#wxevthandlerprocessevent

wxFrame * frame = new wxFrame(...);
...
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, ID_MY_BUTTON);
frame->AddPendingEvent(event);

Regarding how to use this from worker thread - You'd rather take a look at Job Queue http://wxforum.shadonet.com/download.php?id=673

T-Rex