#pragma once #define MAX_THREAD 1 class CInspectThread; class IThreadWorker { public: virtual BOOL OnThreadRun(int iThread, CInspectThread *pInspectThread)= 0; virtual BOOL OnThreadEnd(int iThread, CInspectThread *pInspectThread)= 0; virtual BOOL OnThreadEndAll()= 0;// must be calculated by the Function (OnThreadEnd()) }; class CInspectThread : public CWinThread { DECLARE_DYNCREATE(CInspectThread) protected: BOOL m_bThreadRunning; CRITICAL_SECTION m_csExit; volatile BOOL m_bRunning; BOOL m_bWorking; int m_iThread; int m_iCamera; IThreadWorker *m_pWorker; public: CInspectThread(); virtual ~CInspectThread(); void SetWorker(IThreadWorker *pWorker){m_pWorker= pWorker;} BOOL StartThreadLoop(int iThread); // Ãʱâ void StartThreadWork(){m_bWorking= TRUE;} void StopThread(); BOOL WaitThreadEnd(int ms= 0); BOOL IsRunning(){return m_bRunning;} // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CInspectionThread) public: virtual BOOL InitInstance(); virtual int ExitInstance(); virtual int Run(); //}}AFX_VIRTUAL protected: // Generated message map functions //{{AFX_MSG(CInspectThread) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; class CThreadControl : IThreadWorker { int m_nThreadLoop; // »ý¼ºµÈ Thread Count int m_nWorkingThread; // µ¿ÀÛ[ÀÛ¾÷]À» ½ÃÀÛÇÑ Thread Count CInspectThread *m_pThread; IThreadWorker *m_pThreadWorker; CRITICAL_SECTION m_csWorkingEnd; public: CThreadControl(void); ~CThreadControl(void); public: // 1. Thread ÀÚüÀÇ »ý¼º°ú ¼Ò¸ê¿¡ °ü¿©. int InitThreadControl(int nThread, IThreadWorker* pThreadWorker); BOOL ReleaseThreadControl(); // 2. Thread Loop ¾È¿¡¼­ ÀÛ¾÷ÀÇ Áö½Ã ¿©ºÎ¸¸ ÄÁÆ®·Ñ int StartThreadControl(); void StopThreadControl(); // int GetThreadLoopCount(){return m_nThreadLoop;} int GetThreadWorkingCount(){return m_nWorkingThread;} // Implementation for Interface[IthreadWorker] BOOL OnThreadRun(int iThread, CInspectThread *pInspectThread); BOOL OnThreadEnd(int iThread, CInspectThread *pInspectThread); BOOL OnThreadEndAll(); };