C++内タイマーの使用
3379 ワード
はっきり言って3つの関数の使用です.
SetTimer(20, 20, 0);//1番目の20はこのタイマーの識別子を表し、2番目の20はあなたが決める時間を表し、3番目は気にしないで、0を設定すればいいです.
void CLMS511_interfaceDlg::OnTimer(UINT_PTR nIDEvent){ //TODO: Add your message handler code here and/or call default
if(nIDEvent==20)/この20が最初の20です. { DrawData(); if(MySSocket.StopFlag) SendServer(); }
CDialog::OnTimer(nIDEvent);}
KillTimer(20);//表示が20のタイマーを破棄する
説明:
バージョン
clock_t start = clock();/*code to be tested*/
clock_t end = clock(); cout<
多くの場合、このバージョンはよく知られていません.これは最もよく使われる実行時間テスト方法で、ms級まで正確にすることができます.
SetTimer(20, 20, 0);//1番目の20はこのタイマーの識別子を表し、2番目の20はあなたが決める時間を表し、3番目は気にしないで、0を設定すればいいです.
void CLMS511_interfaceDlg::OnTimer(UINT_PTR nIDEvent){ //TODO: Add your message handler code here and/or call default
if(nIDEvent==20)/この20が最初の20です. { DrawData(); if(MySSocket.StopFlag) SendServer(); }
CDialog::OnTimer(nIDEvent);}
KillTimer(20);//表示が20のタイマーを破棄する
説明:
SetTimer() , 0 , , . NULL,
WM_TIMER , CWnd
SetTimer(1,1,NULL) 1
:
Windows API
SetTimer(HWND,UNIT,UINT,TIMERPROC);
:
1.
2.
3.
4.
CWnd
CWnd::SetTimer
UINT SetTimer(
UINT nIDEvent, //
UINT nElapse, //
void (CALLBACK EXPORT* lpfnTimer)(
HWND, UINT, UINT, DWORD) );
C++ :
unsigned long ticks1,ticks2;
ticks1 = GetTickCount();
ticks2 = GetTickCount();
ticks2-ticks1
ヘッダファイルWinbase.h
:
clock_t start = clock();
clock_t end = clock();
多くの場合、このバージョンはよく知られていません.これは最もよく使われる実行時間テスト方法で、ms級まで正確にすることができます.
TRACE()
TRACE(" :%d",m_DIST[i]);// 。
。%s address 。%d WSAGetLastError() 。
Server "address" Can't Find Code="WSAGetLastError()"
, , TRACE 。
, sleep() 。 windows.h