資源簡介
多線程控制
代碼片段和文件信息
#include?“StdAfx.h“
#include?“SubThread.h“
CSubThread::CSubThread(void)
{
m_pThreadFunction?=?CSubThread::EntryPoint;
m_runthread?=?FALSE;
}
CSubThread::~CSubThread(void)
{
if?(?m_hThread?)
Stop(true);?
}
DWORD?CSubThread::Start(DWORD?dwCreationFlags?=?0)
{
m_runthread?=?true;
m_hThread?=?CreateThread(NULL?0?m_pThreadFunction?this?dwCreationFlags&m_dwTID);
m_dwExitCode?=?(DWORD)-1;
return?GetLastError();
}
DWORD?CSubThread::Stop?(?bool?bForceKill?=?false?)
{
if?(?m_hThread?)
{
//嘗試“溫柔地“結束線程
if?(m_runthread?==?TRUE)
m_runthread?=?FALSE;????????//first?try?to?stop?the?thread?nice
GetExitCodeThread(m_hThread?&m_dwExitCode);
if?(?m_dwExitCode?==?STILL_ACTIVE?&&?bForceKill?)
- 上一篇:對圖像做空間濾波
- 下一篇:C語言經典數據結構算法總結 紅黑樹
評論
共有 條評論