Author: akhaldi
Date: Fri Jul 3 17:17:56 2015
New Revision: 68336
URL:
http://svn.reactos.org/svn/reactos?rev=68336&view=rev
Log:
[TASKMGR] Fix some multi-threaded drawing issues. Brought to you by Joachim Henze.
CORE-9868
Modified:
trunk/reactos/base/applications/taskmgr/perfpage.c
trunk/reactos/base/applications/taskmgr/procpage.c
trunk/reactos/base/applications/taskmgr/taskmgr.c
Modified: trunk/reactos/base/applications/taskmgr/perfpage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/taskmgr/…
==============================================================================
--- trunk/reactos/base/applications/taskmgr/perfpage.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/taskmgr/perfpage.c [iso-8859-1] Fri Jul 3 17:17:56
2015
@@ -22,6 +22,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 @@
ULONG TotalThreads;
ULONG TotalProcesses;
+ MSG msg;
+
WCHAR Text[260];
- WCHAR szMemUsage[256];
-
- MSG msg;
-
+ 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 @@
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 @@
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
@@ -429,6 +440,12 @@
CpuUsage = PerfDataGetProcessorUsage();
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)
{
Modified: trunk/reactos/base/applications/taskmgr/procpage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/taskmgr/…
==============================================================================
--- trunk/reactos/base/applications/taskmgr/procpage.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/taskmgr/procpage.c [iso-8859-1] Fri Jul 3 17:17:56
2015
@@ -419,13 +419,7 @@
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 */
@@ -433,23 +427,11 @@
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();
}
Modified: trunk/reactos/base/applications/taskmgr/taskmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/taskmgr/…
==============================================================================
--- trunk/reactos/base/applications/taskmgr/taskmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/taskmgr/taskmgr.c [iso-8859-1] Fri Jul 3 17:17:56
2015
@@ -952,24 +952,18 @@
{
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)