diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index ba1a3d5083..b8085596d6 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -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); } diff --git a/client/win/wingui_mainwindow.h b/client/win/wingui_mainwindow.h index 024bd86cf9..85871d178d 100755 --- a/client/win/wingui_mainwindow.h +++ b/client/win/wingui_mainwindow.h @@ -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);