mythread.cpp

来自「一个关于线程池的文档」· C++ 代码 · 共 55 行

CPP
55
字号
// myThread.cpp: implementation of the myThread class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ThreadDemo.h"
#include "myThread.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

myThread::myThread()
{
	m_pProgress = NULL;
}

myThread::~myThread()
{

}

BOOL myThread::Work(CProgressCtrl *pProgress)
{
	if(pProgress == NULL)
		return FALSE;

	m_pProgress = pProgress;

	return StartThread();
}

UINT myThread::ThreadMain()
{
	// init progress control
	m_pProgress->SetRange(0, 100);
	m_pProgress->SetPos(0);

	for(int i=0; i<101; ++i)
	{
		if(ShouldDie())
			return 1;

		m_pProgress->SetPos(i);
		Sleep(50);
	}

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?