GetPerformanceCounterLib() static private method

static private GetPerformanceCounterLib ( string machineName, CultureInfo culture ) : PerformanceCounterLib
machineName string
culture CultureInfo
return PerformanceCounterLib
Example #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);
 }
 public static ProcessInfo[] GetProcessInfos(string machineName, bool isRemoteMachine)
 {
     try
     {
         // We don't want to call library.Close() here because that would cause us to unload all of the perflibs.
         // On the next call to GetProcessInfos, we'd have to load them all up again, which is SLOW!
         PerformanceCounterLib library = PerformanceCounterLib.GetPerformanceCounterLib(machineName, new CultureInfo("en"));
         return(GetProcessInfos(library));
     }
     catch (Exception e)
     {
         if (isRemoteMachine)
         {
             throw new InvalidOperationException(SR.CouldntConnectToRemoteMachine, e);
         }
         else
         {
             throw;
         }
     }
 }