public static ProcessInfo[] GetProcessInfos(string machineName, bool isRemoteMachine)
{
PerformanceCounterLib library = null;
try
{
library = PerformanceCounterLib.GetPerformanceCounterLib(machineName, new CultureInfo("en"));
return GetProcessInfos(library);
}
catch (Exception e)
{
if (isRemoteMachine)
{
throw new InvalidOperationException(SR.CouldntConnectToRemoteMachine, e);
}
else
{
throw e;
}
}
// 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!
}