📄 sunnythread.cpp
字号:
// SunnyThread.cpp: implementation of the CSunnyThread class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SunnyThread.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSunnyThread::CSunnyThread(BOOL bAutoDelete /*= FALSE*/) :
m_bAutoDelete(bAutoDelete),
m_hThread(NULL),
m_dwThreadID(0),
m_nRetValue(0),
m_pParam(NULL),
m_pThreadFunc(NULL)
{
}
CSunnyThread::~CSunnyThread()
{
if (m_hThread != NULL)
CloseHandle(m_hThread);
}
BOOL CSunnyThread::Create(THREADFUNC pThreadFunc /*= NULL*/, void* pParam /*= NULL*/, BOOL bSuspended /*= FALSE*/)
{
m_pThreadFunc = pThreadFunc;
m_pParam = pParam;
m_hThread = ::CreateThread(NULL, 0, pThreadFunc, pParam, bSuspended ? CREATE_SUSPENDED : 0, &m_dwThreadID);
return TRUE;
}
BOOL CSunnyThread::WaitForEnd(DWORD dwTiomeout /*= INFINITE*/)
{
if (m_hThread == NULL)
return TRUE;
if (WaitForSingleObject(m_hThread, dwTiomeout) == WAIT_TIMEOUT)
return FALSE;
return TRUE;
}
void CSunnyThread::Resume() const
{
ResumeThread(m_hThread);
}
void CSunnyThread::Suspend() const
{
SuspendThread(m_hThread);
}
BOOL CSunnyThread::SetPriority(int nPriority) const
{
return SetThreadPriority(m_hThread, nPriority);
}
BOOL CSunnyThread::PostMessage(const UINT msg, const WPARAM wParam /*= 0*/, const LPARAM lParam /*= 0*/) const
{
return PostThreadMessage(m_dwThreadID, msg, wParam, lParam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -