The stats are now written once per minute to the settings file.

This commit is contained in:
Kimmo Pekkola 2009-07-27 12:30:28 +00:00
parent b3fc191b58
commit 1dbfc85b01
3 changed files with 17 additions and 9 deletions

View File

@ -1837,6 +1837,7 @@ void CMeterWindow::Update(bool nodraw)
// Statistics // Statistics
CMeasureNet::UpdateStats(); CMeasureNet::UpdateStats();
Rainmeter->WriteStats(false);
if (!nodraw) if (!nodraw)
{ {

View File

@ -631,7 +631,7 @@ CRainmeter::~CRainmeter()
if (m_TrayWindow) delete m_TrayWindow; if (m_TrayWindow) delete m_TrayWindow;
WriteStats(); WriteStats(true);
GdiplusShutdown(m_GDIplusToken); GdiplusShutdown(m_GDIplusToken);
} }
@ -1636,18 +1636,25 @@ void CRainmeter::ReadStats()
/* /*
** WriteStats ** WriteStats
** **
** Writes the statistics to the ini-file ** Writes the statistics to the ini-file. If bForce is false the stats are written only once per minute.
** **
*/ */
void CRainmeter::WriteStats() void CRainmeter::WriteStats(bool bForce)
{ {
// Write the date for statistics static DWORD lastWrite = 0;
WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str());
// Only Net measure has stats at the moment if (bForce || (lastWrite + 1000 * 60 < GetTickCount()))
CMeasureNet::WriteStats(m_IniFile); {
lastWrite = GetTickCount();
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); // Write the date for statistics
WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str());
// Only Net measure has stats at the moment
CMeasureNet::WriteStats(m_IniFile);
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str());
}
} }
/* /*

View File

@ -139,7 +139,7 @@ public:
void UpdateStats(); void UpdateStats();
void ReadStats(); void ReadStats();
void WriteStats(); void WriteStats(bool bForce);
void ResetStats(); void ResetStats();
BOOL GetCheckUpdate() { return m_CheckUpdate; }; BOOL GetCheckUpdate() { return m_CheckUpdate; };