#include "precomp.h"
#include <shlwapi.h>
+extern BOOL bInMenuLoop; /* Tells us if we are in the menu loop - from taskmgr.c */
+
TGraphCtrl PerformancePageCpuUsageHistoryGraph;
TGraphCtrl PerformancePageMemUsageHistoryGraph;
ULONG TotalThreads;
ULONG TotalProcesses;
- WCHAR Text[260];
- WCHAR szMemUsage[256];
-
MSG msg;
+ WCHAR Text[260];
+ WCHAR szMemUsage[256], szCpuUsage[256], szProcesses[256];
+
+ LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256);
+ LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
while (1)
{
szChargeLimitFormat,
sizeof(szChargeLimitFormat));
- wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
- (CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
-
- SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
+ if (!bInMenuLoop)
+ {
+ wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
+ (CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
+ SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
+ }
/*
* Update the kernel memory info
SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
_ultow(TotalProcesses, Text, 10);
SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);
+ if (!bInMenuLoop)
+ {
+ wsprintfW(Text, szProcesses, TotalProcesses);
+ SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)Text);
+ }
/*
* Redraw the graphs
if (CpuUsage <= 0 ) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100;
+ if (!bInMenuLoop)
+ {
+ wsprintfW(Text, szCpuUsage, CpuUsage);
+ SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)Text);
+ }
+
if (TaskManagerSettings.ShowKernelTimes)
{
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
{
- ULONG OldProcessorUsage = 0;
- ULONG OldProcessCount = 0;
- WCHAR szCpuUsage[256], szProcesses[256];
MSG msg;
- LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
- LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
-
while (1) {
/* Wait for an the event or application close */
if (GetMessage(&msg, NULL, 0, 0) <= 0)
return 0;
if (msg.message == WM_TIMER) {
- WCHAR text[260];
UpdateProcesses();
if (IsWindowVisible(hProcessPage))
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
- if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
- OldProcessorUsage = PerfDataGetProcessorUsage();
- wsprintfW(text, szCpuUsage, OldProcessorUsage);
- SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
- }
- if (OldProcessCount != PerfDataGetProcessCount()) {
- OldProcessCount = PerfDataGetProcessCount();
- wsprintfW(text, szProcesses, OldProcessCount);
- SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
- }
-
ProcessPageUpdate();
}
}
{
RECT rc;
int nParts[3];
- WCHAR text[260];
- WCHAR szCpuUsage[256], szProcesses[256];
-
- LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
- LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
bInMenuLoop = FALSE;
+
/* Update the status bar pane sizes */
GetClientRect(hWnd, &rc);
nParts[0] = STATUS_SIZE1;
nParts[1] = STATUS_SIZE2;
nParts[2] = rc.right;
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
- SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)L"");
- wsprintfW(text, szCpuUsage, PerfDataGetProcessorUsage());
- SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
- wsprintfW(text, szProcesses, PerfDataGetProcessCount());
- SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
+
+ /* trigger update of status bar columns and performance page asynchronously */
+ RefreshPerformancePage();
}
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)