+ SetStatusText("Thread stopped.", 1);
+ }
+}
+
+void MyFrame::OnResumeThread(wxCommandEvent& WXUNUSED(event) )
+{
+ wxCriticalSectionLocker enter(wxGetApp().m_critsect);
+
+ // resume first suspended thread
+ size_t n = 0, count = wxGetApp().m_threads.Count();
+ while ( n < count && !wxGetApp().m_threads[n]->IsPaused() )
+ n++;
+
+ if ( n == count )
+ {
+ wxLogError("No thread to resume!");
+ }
+ else
+ {
+ wxGetApp().m_threads[n]->Resume();
+
+ SetStatusText("Thread resumed.", 1);
+ }
+}
+
+void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) )
+{
+ wxCriticalSectionLocker enter(wxGetApp().m_critsect);
+
+ // pause last running thread
+ int n = wxGetApp().m_threads.Count() - 1;
+ while ( n >= 0 && !wxGetApp().m_threads[n]->IsRunning() )
+ n--;
+
+ if ( n < 0 )
+ {
+ wxLogError("No thread to pause!");
+ }
+ else
+ {
+ wxGetApp().m_threads[n]->Pause();
+
+ SetStatusText("Thread paused.", 1);
+ }
+}
+
+// set the frame title indicating the current number of threads
+void MyFrame::OnIdle(wxIdleEvent &event)
+{
+ // update the counts of running/total threads
+ size_t nRunning = 0,
+ nCount = wxGetApp().m_threads.Count();
+ for ( size_t n = 0; n < nCount; n++ )
+ {
+ if ( wxGetApp().m_threads[n]->IsRunning() )
+ nRunning++;
+ }
+
+ if ( nCount != m_nCount || nRunning != m_nRunning )
+ {
+ m_nRunning = nRunning;
+ m_nCount = nCount;
+
+ wxLogStatus(this, "%u threads total, %u running.", nCount, nRunning);
+ }
+ //else: avoid flicker - don't print anything
+}
+
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
+{
+ size_t count = wxGetApp().m_threads.Count();
+ for ( size_t i = 0; i < count; i++ )
+ {
+ wxGetApp().m_threads[0]->Delete();
+ }
+
+ Close(TRUE);
+}
+
+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\n"
+ "(c) 2000 Robert Roebling",
+ "About wxThread sample",
+ wxOK | wxICON_INFORMATION);
+
+ dialog.ShowModal();
+}
+
+void MyFrame::OnClear(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef TRACE
+ // log a separator
+ wxLogTrace("-------- log window cleared --------");
+#endif
+
+ m_txtctrl->Clear();
+}
+
+void MyFrame::OnUpdateWorker(wxUpdateUIEvent& event)