mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:35:47 +00:00
[TASKMGR] Fix some multi-threaded drawing issues. Brought to you by Joachim Henze. CORE-9868
svn path=/trunk/; revision=68336
This commit is contained in:
parent
27e12f2db6
commit
90e11c6263
3 changed files with 28 additions and 35 deletions
|
@ -23,6 +23,8 @@
|
|||
#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;
|
||||
|
||||
|
@ -331,12 +333,14 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
|||
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)
|
||||
{
|
||||
|
@ -373,10 +377,12 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
|||
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
|
||||
|
@ -416,6 +422,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
|||
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
|
||||
|
@ -430,6 +441,12 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
|||
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();
|
||||
|
|
|
@ -419,38 +419,20 @@ void RefreshProcessPage(void)
|
|||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -952,24 +952,18 @@ void TaskManager_OnExitMenuLoop(HWND hWnd)
|
|||
{
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue