[問題] VC++ timer做的計時器誤差
開發平台(Platform): (Ex: VC++, Gcc, Linux, ...)
VC++
問題(Question):
我使用VC++裡面內建的timer寫了一個計時器,預計精準到秒小數點後兩位。
但發現電腦在跑的時候,顯示的部分明顯比實際時間久,
例:實際時間十秒 程式可能只跑了八秒半。
餵入的資料(Input):
按鈕控制 開始/結束,interval設10。
預期的正確結果(Expected Output):
正確的顯示經過時間。
錯誤結果(Wrong Output):
程式跑得較慢。
程式碼(Code): (請善用置底文標色功能)
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^
e)
{
decimal+=1;
if ( decimal == 100 )
{
decimal = 0;
second += 1;
if ( second == 60 )
{
second = 0;
minute += 1;
if ( minute == 60 )
{
minute = 0;
hour += 1;
}
}
}
this->label1->Text = hour + ":" + minute + ":" + second + "." + decimal;
}
補充說明(Supplement):
我今天第一次動手寫VC++,只找的到debug資料夾 找不到release資料夾,
想順道一問,怎麼樣release。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.251.208.213
→
01/01 23:35, , 1F
01/01 23:35, 1F
→
01/01 23:36, , 2F
01/01 23:36, 2F
推
01/02 00:02, , 3F
01/02 00:02, 3F
→
01/02 00:04, , 4F
01/02 00:04, 4F
→
01/02 01:22, , 5F
01/02 01:22, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
11
38