标签:
//ThreadBase.h
#pragma once #include<windows.h> class CThreadBase { public: CThreadBase(void); ~CThreadBase(void); static DWORD WINAPI ThreadProc (PVOID pParam); virtual void Run() = 0; void Start(); private: HANDLE m_hThread; DWORD m_dwThreadID; };
//ThreadBase.cpp #include "StdAfx.h" #include "ThreadBase.h" CThreadBase::CThreadBase(void) { m_hThread = CreateThread(NULL,0,ThreadProc,this,CREATE_SUSPENDED,&m_dwThreadID); } CThreadBase::~CThreadBase(void) { CloseHandle(m_hThread); } DWORD WINAPI CThreadBase::ThreadProc (PVOID pParam) { if (NULL!=pParam) { ((CThreadBase*)pParam)->Run(); } return 0; } void CThreadBase::Start() { ResumeThread(m_hThread); }
标签:
原文地址:http://www.cnblogs.com/Neu400753645/p/4274805.html