1 // VirtThread.h 2 3 #ifndef ZIP7_INC_VIRT_THREAD_H 4 #define ZIP7_INC_VIRT_THREAD_H 5 6 #include "../../Windows/Synchronization.h" 7 #include "../../Windows/Thread.h" 8 9 struct CVirtThread 10 { 11 NWindows::NSynchronization::CAutoResetEvent StartEvent; 12 NWindows::NSynchronization::CAutoResetEvent FinishedEvent; 13 NWindows::CThread Thread; 14 bool Exit; 15 ~CVirtThreadCVirtThread16 virtual ~CVirtThread() { WaitThreadFinish(); } 17 void WaitThreadFinish(); // call it in destructor of child class ! 18 WRes Create(); 19 WRes Start(); 20 virtual void Execute() = 0; WaitExecuteFinishCVirtThread21 WRes WaitExecuteFinish() { return FinishedEvent.Lock(); } 22 }; 23 24 #endif 25