windows timer fix

svn path=/trunk/boinc/; revision=876
This commit is contained in:
Eric Heien 2003-02-06 19:40:52 +00:00
parent 10c9904d5b
commit eedb936576
2 changed files with 9 additions and 9 deletions

View File

@ -1464,7 +1464,7 @@ int CMainWindow::OnCreate(LPCREATESTRUCT lpcs)
return 0;
}
SetTimer(ID_TIMER, TIMEOUT_WAIT, (TIMERPROC) NULL);
m_nTimerID = SetTimer(ID_TIMER, TIMEOUT_WAIT, (TIMERPROC) NULL);
// load dll and start idle detection
m_hIdleDll = LoadLibrary("boinc.dll");
@ -1696,12 +1696,8 @@ LRESULT CMainWindow::OnStatusIcon(WPARAM wParam, LPARAM lParam)
// and updates gui display.
void CMainWindow::OnTimer(UINT uEventID)
{
// refresh_count is used so we only update the GUI once a
// second regardless of the TIMEOUT_WAIT value
static int refresh_count = 0;
// stop the timer while we do processing
KillTimer(ID_TIMER);
KillTimer(m_nTimerID);
// update state and gui
while(gstate.do_something());
NetCheck(); // need to check if network connection can be terminated
@ -1719,10 +1715,12 @@ void CMainWindow::OnTimer(UINT uEventID)
gstate.user_idle = true;
}
if (refresh_count == 0)
// m_nRefreshCount is used so we only update the GUI once a
// second regardless of the TIMEOUT_WAIT value
if (m_nRefreshCount == 0)
UpdateGUI(&gstate);
}
refresh_count = (refresh_count+1)%(1000/TIMEOUT_WAIT);
m_nRefreshCount = (m_nRefreshCount+1)%(1000/TIMEOUT_WAIT);
// Start the timer again
SetTimer(ID_TIMER, TIMEOUT_WAIT, (TIMERPROC) NULL);
m_nTimerID = SetTimer(ID_TIMER, TIMEOUT_WAIT, (TIMERPROC) NULL);
}

View File

@ -111,6 +111,8 @@ protected:
BOOL m_bRequest; // does the user have a net connection request?
BOOL m_bSuspend; // should apps be suspended?
int m_nContextItem; // item selected for context menu
int m_nRefreshCount; // countdown for GUI refreshing
UINT m_nTimerID; // ID of current GUI timer
COLORREF GetPieColor(int);
void ShowTab(int);