1
- // COPYRIGHT 2011, 2012, 2013 by the Open Rails project.
1
+ // COPYRIGHT 2011, 2012, 2013 by the Open Rails project.
2
2
//
3
3
// This file is part of Open Rails.
4
4
//
@@ -112,14 +112,15 @@ public HUDWindow(WindowManager owner)
112
112
ProcessMemoryCounters = new PROCESS_MEMORY_COUNTERS ( ) { Size = 40 } ;
113
113
ProcessVirtualAddressLimit = GetVirtualAddressLimit ( ) ;
114
114
115
+ var processId = Process . GetCurrentProcess ( ) . Id ;
115
116
try
116
117
{
117
118
var counterDotNetClrMemory = new PerformanceCounterCategory ( ".NET CLR Memory" ) ;
118
- foreach ( var process in counterDotNetClrMemory . GetInstanceNames ( ) )
119
+ foreach ( InstanceData instance in counterDotNetClrMemory . ReadCategory ( ) [ "Process ID" ] . Values )
119
120
{
120
- var processId = new PerformanceCounter ( ".NET CLR Memory" , "Process ID" , process ) ;
121
- if ( processId . NextValue ( ) == Process . GetCurrentProcess ( ) . Id )
121
+ if ( instance . RawValue == processId )
122
122
{
123
+ var process = instance . InstanceName ;
123
124
CLRMemoryAllocatedBytesPerSecCounter = new PerformanceCounter ( ".NET CLR Memory" , "Allocated Bytes/sec" , process ) ;
124
125
Trace . TraceInformation ( $ "Found Microsoft .NET Framework performance counter { process } ") ;
125
126
break ;
@@ -135,11 +136,11 @@ public HUDWindow(WindowManager owner)
135
136
try
136
137
{
137
138
var counterProcess = new PerformanceCounterCategory ( "Process" ) ;
138
- foreach ( var process in counterProcess . GetInstanceNames ( ) )
139
+ foreach ( InstanceData instance in counterProcess . ReadCategory ( ) [ "ID Process" ] . Values )
139
140
{
140
- var processId = new PerformanceCounter ( "Process" , "ID Process" , process ) ;
141
- if ( processId . NextValue ( ) == Process . GetCurrentProcess ( ) . Id )
141
+ if ( instance . RawValue == processId )
142
142
{
143
+ var process = instance . InstanceName ;
143
144
CPUMemoryPrivateCounter = new PerformanceCounter ( "Process" , "Private Bytes" , process ) ;
144
145
CPUMemoryWorkingSetCounter = new PerformanceCounter ( "Process" , "Working Set" , process ) ;
145
146
CPUMemoryWorkingSetPrivateCounter = new PerformanceCounter ( "Process" , "Working Set - Private" , process ) ;
0 commit comments