Created
October 14, 2014 03:11
-
-
Save SimonCropp/8a5cd61fe360da9dc66c to your computer and use it in GitHub Desktop.
PerformanceMonitor.GetData
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal byte[] GetData(string item) | |
| { | |
| int num = 17; | |
| int millisecondsTimeout = 0; | |
| int error = 0; | |
| new RegistryPermission(PermissionState.Unrestricted).Assert(); | |
| while (num > 0) | |
| { | |
| try | |
| { | |
| return (byte[]) this.perfDataKey.GetValue(item); | |
| } | |
| catch (IOException ex) | |
| { | |
| error = Marshal.GetHRForException((Exception) ex); | |
| switch (error) | |
| { | |
| case 1722: | |
| case 1726: | |
| case 6: | |
| this.Init(); | |
| goto case 170; | |
| case 170: | |
| case 258: | |
| case 21: | |
| case 167: | |
| --num; | |
| if (millisecondsTimeout == 0) | |
| { | |
| millisecondsTimeout = 10; | |
| continue; | |
| } | |
| else | |
| { | |
| Thread.Sleep(millisecondsTimeout); | |
| millisecondsTimeout *= 2; | |
| continue; | |
| } | |
| default: | |
| throw SharedUtils.CreateSafeWin32Exception(error); | |
| } | |
| } | |
| catch (InvalidCastException ex) | |
| { | |
| throw new InvalidOperationException(SR.GetString("CounterDataCorrupt", new object[1] | |
| { | |
| (object) this.perfDataKey.ToString() | |
| }), (Exception) ex); | |
| } | |
| } | |
| throw SharedUtils.CreateSafeWin32Exception(error); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment