]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/thread.h
wxUniv/MSW compilation fix in wxWindowBase::GetDlgUnitBase().
[wxWidgets.git] / interface / wx / thread.h
index 328879c901a8cea3018c917f51a0ea9e5a7b2456..52b94f3128992cc7bf6cffd8408ca5a4fa3442d5 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     interface of all thread-related wxWidgets classes
 // Author:      wxWidgets team
 // RCS-ID:      $Id$
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 
@@ -309,14 +309,14 @@ public:
             char m_data[1024];
             wxCriticalSection m_dataCS; // protects field above
 
-            DECLARE_EVENT_TABLE()
+            wxDECLARE_EVENT_TABLE();
         };
 
         wxDEFINE_EVENT(wxEVT_COMMAND_MYTHREAD_UPDATE, wxThreadEvent)
-        BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+        wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
             EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_UPDATE, MyFrame::OnThreadUpdate)
             EVT_CLOSE(MyFrame::OnClose)
-        END_EVENT_TABLE()
+        wxEND_EVENT_TABLE()
 
         void MyFrame::DoStartALongTask()
         {
@@ -454,6 +454,37 @@ public:
     */
     virtual ExitCode Entry() = 0;
 
+    /**
+        Callback called by Delete() before actually deleting the thread.
+
+        This function can be overridden by the derived class to perform some
+        specific task when the thread is gracefully destroyed. Notice that it
+        will be executed in the context of the thread that called Delete() and
+        <b>not</b> in this thread's context.
+
+        TestDestroy() will be true for the thread before OnDelete() gets
+        executed.
+
+        @since 2.9.2
+
+        @see OnKill()
+    */
+    virtual void OnDelete();
+
+    /**
+        Callback called by Kill() before actually killing the thread.
+
+        This function can be overridden by the derived class to perform some
+        specific task when the thread is terminated. Notice that it will be
+        executed in the context of the thread that called Kill() and <b>not</b>
+        in this thread's context.
+
+        @since 2.9.2
+
+        @see OnDelete()
+    */
+    virtual void OnKill();
+
     /**
         @deprecated
         Use CreateThread() instead.
@@ -687,15 +718,15 @@ enum
         MyThread *m_pThread;
         wxCriticalSection m_pThreadCS;    // protects the m_pThread pointer
 
-        DECLARE_EVENT_TABLE()
+        wxDECLARE_EVENT_TABLE();
     };
 
-    BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+    wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
         EVT_CLOSE(MyFrame::OnClose)
         EVT_MENU(Minimal_Start,  MyFrame::DoStartThread)
         EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_UPDATE, MyFrame::OnThreadUpdate)
         EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MYTHREAD_COMPLETED, MyFrame::OnThreadCompletion)
-    END_EVENT_TABLE()
+    wxEND_EVENT_TABLE()
 
     wxDEFINE_EVENT(wxEVT_COMMAND_MYTHREAD_COMPLETED, wxThreadEvent)
     wxDEFINE_EVENT(wxEVT_COMMAND_MYTHREAD_UPDATE, wxThreadEvent)
@@ -788,7 +819,7 @@ enum
 
             if (m_pThread)         // does the thread still exist?
             {
-                m_out.Printf("MYFRAME: deleting thread");
+                wxMessageOutputDebug().Printf("MYFRAME: deleting thread");
 
                 if (m_pThread->Delete() != wxTHREAD_NO_ERROR )
                     wxLogError("Can't delete the thread!");
@@ -1125,6 +1156,10 @@ public:
         of detached threads.
 
         This function can only be called from another thread context.
+        
+        Finally, note that once a thread has completed and its Entry() function
+        returns, you cannot call Run() on it again (an assert will fail in debug
+        builds or @c wxTHREAD_RUNNING will be returned in release builds).
     */
     wxThreadError Run();