?? event.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 + -