Hello all
I need an accurate timer in windows CE.
for testing WinCE timers, I wrote a tiny program, that sets two timer.
One of them 1 milisec and another 5000 milisec and I set the pariority of current thread to Time_Critical.
In first timer tick I increment a counter and in second timer tick(every 5 sec) I show the value of counter. but the value is not correct and it is the half of that I expect!!
Code
- BOOL CTimersDlg::OnInitDialog()
- {
- ....
- // TODO: Add extra initialization here
- CeSetThreadPriority(GetCurrentThread(),
- THREAD_PRIORITY_TIME_CRITICAL);
- T0C = 1;
- T0Id = SetTimer(1, 1 , NULL);
- if (T0Id == 0)
- return FALSE;
- T2Id = SetTimer(5000, 5000 , NULL);
- if (T2Id == 0)
- return FALSE;
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CTimersDlg::OnTimer(UINT nIDEvent)
- {
- switch (nIDEvent)
- {
- case 1:
- T0C++;
- break;
- case 5000:
- m_T.Format(_T("T0: %d"), T0C);
- UpdateData(FALSE);
- break;
- }
- CDialog::OnTimer(nIDEvent);
- }
How can set an accurate timer in WinCE?
Is my code wrong?
Thanks
[edit HK: code tags for program]