System.Diagnostics.PerformanceCounterLib.GetPerformanceCounterLib C# (CSharp) Method

GetPerformanceCounterLib() static private method

static private GetPerformanceCounterLib ( string machineName, CultureInfo culture ) : PerformanceCounterLib
machineName string
culture CultureInfo
return PerformanceCounterLib
        internal static PerformanceCounterLib GetPerformanceCounterLib(string machineName, CultureInfo culture)
        {
            string lcidString = culture.Name.ToLowerInvariant();
            if (machineName.CompareTo(".") == 0)
                machineName = ComputerName.ToLowerInvariant();
            else
                machineName = machineName.ToLowerInvariant();

            if (PerformanceCounterLib.s_libraryTable == null)
            {
                lock (InternalSyncObject)
                {
                    if (PerformanceCounterLib.s_libraryTable == null)
                        PerformanceCounterLib.s_libraryTable = new Dictionary<string, PerformanceCounterLib>();
                }
            }

            string libraryKey = machineName + ":" + lcidString;
            PerformanceCounterLib library;
            if (!PerformanceCounterLib.s_libraryTable.TryGetValue(libraryKey, out library))
            {
                library = new PerformanceCounterLib(machineName, lcidString);
                PerformanceCounterLib.s_libraryTable[libraryKey] = library;
            }
            return library;
        }

Usage Example

Beispiel #1
0
 public static ProcessInfo[] GetProcessInfos(string machineName, bool isRemoteMachine)
 {
     ProcessInfo[] processInfos;
     new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
     try
     {
         processInfos = GetProcessInfos(PerformanceCounterLib.GetPerformanceCounterLib(machineName, new CultureInfo(9)));
     }
     catch (Exception exception)
     {
         if (isRemoteMachine)
         {
             throw new InvalidOperationException(SR.GetString("CouldntConnectToRemoteMachine"), exception);
         }
         throw exception;
     }
     return(processInfos);
 }
All Usage Examples Of System.Diagnostics.PerformanceCounterLib::GetPerformanceCounterLib