+MyWorkerThread::MyWorkerThread(MyFrame *frame)
+ : wxThread()
+{
+ m_frame = frame;
+ m_count = 0;
+}
+
+void MyWorkerThread::OnExit()
+{
+}
+
+void *MyWorkerThread::Entry()
+{
+ for ( m_count = 0; m_count < 10; m_count++ )
+ {
+ // check if we were asked to exit
+ if ( TestDestroy() )
+ break;
+
+ wxString text;
+ text.Printf("[%u] Thread 0x%x here!!", m_count, GetId());
+
+ // create any type of command event here
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, WORKER_EVENT );
+ event.SetInt( WORKER_EVENT );
+ event.SetString( text );
+
+ // send in a thread-safe way
+ wxPostEvent( m_frame, event );
+
+ // same as:
+ // m_frame->AddPendingEvent( event );
+
+ // wxSleep() can't be called from non-main thread!
+ wxThread::Sleep(1000);
+ }
+
+ return NULL;
+}
+
+//--------------------------------------------------
+// main program
+//--------------------------------------------------
+