mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:03:12 +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 "precomp.h"
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
|
extern BOOL bInMenuLoop; /* Tells us if we are in the menu loop - from taskmgr.c */
|
||||||
|
|
||||||
TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
||||||
TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
||||||
|
|
||||||
|
@ -331,12 +333,14 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
||||||
ULONG TotalThreads;
|
ULONG TotalThreads;
|
||||||
ULONG TotalProcesses;
|
ULONG TotalProcesses;
|
||||||
|
|
||||||
WCHAR Text[260];
|
|
||||||
WCHAR szMemUsage[256];
|
|
||||||
|
|
||||||
MSG msg;
|
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_MEMUSAGE, szMemUsage, 256);
|
||||||
|
LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -373,10 +377,12 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
||||||
szChargeLimitFormat,
|
szChargeLimitFormat,
|
||||||
sizeof(szChargeLimitFormat));
|
sizeof(szChargeLimitFormat));
|
||||||
|
|
||||||
|
if (!bInMenuLoop)
|
||||||
|
{
|
||||||
wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
|
wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
|
||||||
(CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
|
(CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
|
||||||
|
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
|
SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the kernel memory info
|
* Update the kernel memory info
|
||||||
|
@ -416,6 +422,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
||||||
SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
|
SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text);
|
||||||
_ultow(TotalProcesses, Text, 10);
|
_ultow(TotalProcesses, Text, 10);
|
||||||
SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);
|
SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text);
|
||||||
|
if (!bInMenuLoop)
|
||||||
|
{
|
||||||
|
wsprintfW(Text, szProcesses, TotalProcesses);
|
||||||
|
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)Text);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Redraw the graphs
|
* Redraw the graphs
|
||||||
|
@ -430,6 +441,12 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
||||||
if (CpuUsage <= 0 ) CpuUsage = 0;
|
if (CpuUsage <= 0 ) CpuUsage = 0;
|
||||||
if (CpuUsage > 100) CpuUsage = 100;
|
if (CpuUsage > 100) CpuUsage = 100;
|
||||||
|
|
||||||
|
if (!bInMenuLoop)
|
||||||
|
{
|
||||||
|
wsprintfW(Text, szCpuUsage, CpuUsage);
|
||||||
|
SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)Text);
|
||||||
|
}
|
||||||
|
|
||||||
if (TaskManagerSettings.ShowKernelTimes)
|
if (TaskManagerSettings.ShowKernelTimes)
|
||||||
{
|
{
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||||
|
|
|
@ -419,38 +419,20 @@ void RefreshProcessPage(void)
|
||||||
|
|
||||||
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
|
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
|
||||||
{
|
{
|
||||||
ULONG OldProcessorUsage = 0;
|
|
||||||
ULONG OldProcessCount = 0;
|
|
||||||
WCHAR szCpuUsage[256], szProcesses[256];
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
|
|
||||||
LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Wait for an the event or application close */
|
/* Wait for an the event or application close */
|
||||||
if (GetMessage(&msg, NULL, 0, 0) <= 0)
|
if (GetMessage(&msg, NULL, 0, 0) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (msg.message == WM_TIMER) {
|
if (msg.message == WM_TIMER) {
|
||||||
WCHAR text[260];
|
|
||||||
|
|
||||||
UpdateProcesses();
|
UpdateProcesses();
|
||||||
|
|
||||||
if (IsWindowVisible(hProcessPage))
|
if (IsWindowVisible(hProcessPage))
|
||||||
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
|
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();
|
ProcessPageUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,24 +952,18 @@ void TaskManager_OnExitMenuLoop(HWND hWnd)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
int nParts[3];
|
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;
|
bInMenuLoop = FALSE;
|
||||||
|
|
||||||
/* Update the status bar pane sizes */
|
/* Update the status bar pane sizes */
|
||||||
GetClientRect(hWnd, &rc);
|
GetClientRect(hWnd, &rc);
|
||||||
nParts[0] = STATUS_SIZE1;
|
nParts[0] = STATUS_SIZE1;
|
||||||
nParts[1] = STATUS_SIZE2;
|
nParts[1] = STATUS_SIZE2;
|
||||||
nParts[2] = rc.right;
|
nParts[2] = rc.right;
|
||||||
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)L"");
|
|
||||||
wsprintfW(text, szCpuUsage, PerfDataGetProcessorUsage());
|
/* trigger update of status bar columns and performance page asynchronously */
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
|
RefreshPerformancePage();
|
||||||
wsprintfW(text, szProcesses, PerfDataGetProcessCount());
|
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue