?? thread.h
字號:
//This piece of code has been written in University of Hull by
//Warren Viant then Head of Department
//in Department of Computer Science
//Some alteration have been made by me
#pragma once
#include <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
class Thread
{
private:
HANDLE _hThread;
bool _terminate;
bool _isRunning;
static unsigned __stdcall threadFunc(void *param) {
if (param)
return ((Thread*)param)->run();
return 1; // Return error
}
public:
Thread() : _hThread(0), _terminate(false) {}
virtual ~Thread() {}
void terminate() { _terminate = true; _isRunning = false; CloseHandle(_hThread);
_hThread=0; }
bool isTerminated() const { return _terminate; }
bool isThreadRunning()const{ return _isRunning ; }
void reset() { _terminate = false; _isRunning = false ;}
void SetRunningStatus() { _isRunning = true ;}
HANDLE start();
void waitForTermination();
virtual int run() = 0;
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -