⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 event.h

📁 实时监控
💻 H
字号:
#ifndef _EVENT_H
#define _EVENT_H

class event
{
	HANDLE h;
public:
	event():h(NULL)
	{
		h = CreateEvent(NULL, TRUE, FALSE, NULL);
	}

	event(bool initial): h(NULL)
	{
		h = CreateEvent(NULL, TRUE, initial!=false, NULL);
	}
	event(bool manual, bool initial): h(NULL)
	{
		h = CreateEvent(NULL, manual==true, initial!=false, NULL);
	}
	~event()
	{
		if(h)
		{
			CloseHandle(h);
			h = NULL;
		}
	}
/*
	bool create(bool initial=false)
	{
		destroy();

		h = CreateEvent(NULL, TRUE, initial!=false, NULL);
		return h != NULL;
	}

	void destroy()
	{
		if(h)
		{
			CloseHandle(h);
			h = NULL;
		}
	}
*/

	void set(){	SetEvent(h);}
	void reset(){ResetEvent(h);}
	void pulse(){PulseEvent(h);}
	operator bool(){return wait(0);}
	bool operator!() {return !(bool)(*this);}
	bool wait(DWORD timeout=INFINITE)
	{
		return WaitForSingleObject(h, timeout) == WAIT_OBJECT_0;
	}
	HANDLE handle() {return h;}
};
#endif	// _EVENT_H

⌨️ 快捷键说明

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