]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/thread/test.cpp
SN: Fixes to OS/2 specific problems (use LEX_STEM and PATH_IFS set by configure).
[wxWidgets.git] / samples / thread / test.cpp
index 7996d8f532fa917a89872c95957e2d11ae4a158f..5788b0caa23b612fcda26417e3d26b74060f449d 100644 (file)
@@ -155,7 +155,6 @@ void MyThread::WriteText(const wxString& text)
     wxMutexGuiEnter();
 
     msg << text;
-
     m_frame->WriteText(msg);
     
     wxMutexGuiLeave();
@@ -235,11 +234,21 @@ void *MyWorkerThread::Entry()
         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-GUI thread!
+        // wxSleep() can't be called from non-main thread!
         wxThread::Sleep(1000);
     }
 
@@ -495,7 +504,8 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
 {
     wxMessageDialog dialog(this, "wxWindows multithreaded application sample\n"
                                  "(c) 1998 Julian Smart, Guilhem Lavaux\n"
-                                 "(c) 1999 Vadim Zeitlin",
+                                 "(c) 1999 Vadim Zeitlin\n"
+                                 "(c) 2000 Robert Roebling",
                            "About wxThread sample",
                            wxOK | wxICON_INFORMATION);
 
@@ -519,8 +529,10 @@ void MyFrame::OnStartWorker(wxCommandEvent& WXUNUSED(event))
     thread->Run();
 }
 
-void MyFrame::OnWorkerEvent(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
 {
-    WriteText( "Got message from worker thread\n" );
+    WriteText( "Got message from worker thread: " );
+    WriteText( event.GetString() );
+    WriteText( "\n" );
 }