Thread.h
上传用户:glass0516
上传日期:2010-01-11
资源大小:104k
文件大小:2k
- /*****************************************************************************
- * RelayFax Open Source Project
- * Copyright 1996-2004 Alt-N Technologies, Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the RelayFax Open
- * Source License. A copy of this license is available in file LICENSE
- * in the top-level directory of the distribution.
- *
- * RelayFax is a registered trademark of Alt-N Technologies, Ltd.
- *
- * Individual files and/or contributed packages may be copyright by
- * other parties and subject to additional restrictions.
- *****************************************************************************/
- #ifndef THREAD_H
- #define THREAD_H
- class CThread
- {
- public:
- // Constructor
- CThread();
- virtual ~CThread();
- // The static thread starter function
- static unsigned int _stdcall ThreadFunc( void* pArg );
- // Do not override these
- void AddEvent( HANDLE hEvent ) { m_handles.push_back( hEvent ); }
- DWORD StartThread( void );
- HANDLE GetHandle( void ) { return m_hThread; }
- unsigned int GetID( void ) { return m_nThreadID; }
- unsigned int Run( void );
- void PostMsg( UINT nMsg, WPARAM wParam=0, LPARAM lParam=0 )
- { PostThreadMessage( m_nThreadID, nMsg, wParam, lParam ); }
- // overrideables
- virtual bool OnStartup( void );
- virtual bool OnMsg( MSG* pMsg );
- virtual bool OnEvent( int nIndex );
- virtual bool OnWaitTimeout( void );
- virtual void OnShutdown( void );
- protected:
- vector<HANDLE> m_handles;
- HANDLE m_hThread;
- unsigned int m_nThreadID;
- int m_nWaitTimeout;
- string m_sThreadName;
- DWORD m_dwLastTimeout;
- };
- #endif // THREAD_H