//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 03/09/2001 // PROJECT: // SUBSYSTEM: // FILE: Thread1.h // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Header file of Thread1.h //---------------------------------------------------------------------------- #ifndef __THREAD__H__INCLUDED__ #define __THREAD__H__INCLUDED__ #if _MSC_VER > 1000 #pragma once #endif class CThread { public: CThread(); virtual ~CThread(); public: virtual BOOL Start( BOOL bSelfDestroy ); virtual BOOL Stop( BOOL bWaitForComplete ); virtual BOOL IsStopping() { return m_hEventStopThread ? WaitForSingleObject( m_hEventStopThread, 0UL ) == WAIT_OBJECT_0 : FALSE; } public: virtual DWORD GetThreadId() { return m_dwThreadId; } virtual HANDLE GetThreadHandle() { return m_hThread; } virtual HANDLE GetThreadStopEvent() { return m_hEventStopThread; } protected: virtual DWORD ThreadProc() = 0; private: enum { MAX_THREAD_CLOSE_TIME = 10000UL }; static UINT CALLBACK ThreadProc( LPVOID ); private: HANDLE m_hThread; DWORD m_dwThreadId; HANDLE m_hEventStopThread; BOOL m_bSelfDestroy; }; #endif