64,637
社区成员
发帖
与我相关
我的任务
分享
void CLogFile::Start()
{
m_hThread = (HANDLE)_beginthreadex(NULL, 0, &CLogFile::Run, NULL, 0, NULL);
}
void CLogFile::Run()
{
while(true)
{
Sleep(1);
WriteLog();
if (m_isStop)
break;
}
}
void CLogFile::Stop()
{
if (m_isStop)
return;
m_isStop = true;
WaitForSingleObject(m_hThread, INFINITE);
CloseHandle(m_hThread);
}
)_beginthreadex(NULL, 0, RunFunc, 你的对象指针, 0, NULL);
在RunFunc函数中,获得传入的对象。调用对象中的方法即可。