counterthread.cpp
来自「从学案例入手」· C++ 代码 · 共 59 行
CPP
59 行
// CounterThread.cpp: implementation of the CCounterThread class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "UIThread.h"
#include "CounterThread.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CCounterThread,CExampleThread)
CCounterThread::CCounterThread()
{
}
CCounterThread::~CCounterThread()
{
}
CCounterThread::Run()
{
BOOL fSyncChecked;
CString strBuffer;
ASSERT(m_pOwner != NULL);
if (m_pOwner == NULL)
return -1;
CSingleLock sLock(&(m_pOwner->m_mutex));
while (!m_bDone)
{
fSyncChecked = m_pOwner->IsDlgButtonChecked(IDC_SYNCHRONIZE);
if (fSyncChecked)
sLock.Lock();
//构建要显示的字符串
strBuffer=_T("Display: ");
strBuffer+=m_pOwner->m_strNumber;
if (fSyncChecked)
sLock.Unlock();
//将字符串加入到列表框中
m_pOwner->AddToListBox(strBuffer);
Sleep(1000);
}//结束while
m_pOwner->PostMessage(WM_CLOSE, 0, 0L);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?