thread.h

来自「串口通信mfc源码」· C头文件 代码 · 共 42 行

H
42
字号
// ***************************************************************
//  Thread   version:  1.0   ·  date: 06/30/2006
//  -------------------------------------------------------------
//  Wrapper Thread operation
//  -------------------------------------------------------------
//  Copyright (C) 2001-2006 - Midapexsoft All Rights Reserved
// ***************************************************************
// 
// ***************************************************************
#pragma once

class CThread
{
public:
	CThread();
	virtual ~CThread();

	HANDLE GetHandle() const;
	void Wait() const;
	bool Wait(DWORD timeoutMillis) const;
	void Start();
	void Terminate(DWORD exitCode = 0);
	void SetPriority(int priority);

	unsigned int  GetThreadID() const { return m_dwId;}
	
protected:
	//it can be overrided for your purpose
	virtual int Run() = 0; 

private :
	static unsigned int __stdcall ThreadFunction(void *pV);
	HANDLE m_hThread;
	unsigned int  m_dwId;

	// No copies
	CThread(const CThread &rhs);
	CThread &operator=(const CThread &rhs);
};


⌨️ 快捷键说明

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