PerformanceCounter.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //
  2. // System.Diagnostics.PerformanceCounter.cs
  3. //
  4. // Authors:
  5. // Jonathan Pryor ([email protected])
  6. //
  7. // (C) 2002
  8. //
  9. using System;
  10. using System.ComponentModel;
  11. using System.Diagnostics;
  12. namespace System.Diagnostics {
  13. // must be safe for multithreaded operations
  14. public class PerformanceCounter : Component, ISupportInitialize {
  15. private string categoryName;
  16. private string counterName;
  17. private string instanceName;
  18. private string machineName;
  19. private bool readOnly;
  20. [MonoTODO("Find the actual value")]
  21. public static int DefaultFileMappingSize = 0x80000;
  22. // set catname, countname, instname to "", machname to "."
  23. public PerformanceCounter ()
  24. {
  25. categoryName = counterName = instanceName = "";
  26. machineName = ".";
  27. }
  28. // throws: InvalidOperationException (if catName or countName
  29. // is ""); ArgumentNullException if either is null
  30. // sets instName to "", machname to "."
  31. public PerformanceCounter (String categoryName,
  32. string counterName)
  33. : this (categoryName, counterName, false)
  34. {
  35. }
  36. public PerformanceCounter (string categoryName,
  37. string counterName,
  38. bool readOnly)
  39. : this (categoryName, counterName, "", readOnly)
  40. {
  41. }
  42. public PerformanceCounter (string categoryName,
  43. string counterName,
  44. string instanceName)
  45. : this (categoryName, counterName, instanceName, false)
  46. {
  47. }
  48. public PerformanceCounter (string categoryName,
  49. string counterName,
  50. string instanceName,
  51. bool readOnly)
  52. {
  53. CategoryName = categoryName;
  54. CounterName = counterName;
  55. if (categoryName == "" || counterName == "")
  56. throw new InvalidOperationException ();
  57. InstanceName = instanceName;
  58. this.instanceName = instanceName;
  59. this.machineName = ".";
  60. this.readOnly = readOnly;
  61. }
  62. public PerformanceCounter (string categoryName,
  63. string counterName,
  64. string instanceName,
  65. string machineName)
  66. : this (categoryName, counterName, instanceName, false)
  67. {
  68. this.machineName = machineName;
  69. }
  70. // may throw ArgumentNullException
  71. public string CategoryName {
  72. get {return categoryName;}
  73. set {
  74. if (value == null)
  75. throw new ArgumentNullException ("categoryName");
  76. categoryName = value;
  77. }
  78. }
  79. // // may throw InvalidOperationException
  80. // [MonoTODO]
  81. // public string CounterHelp {
  82. // get {return "";}
  83. // }
  84. //
  85. // may throw ArgumentNullException
  86. public string CounterName {
  87. get {return counterName;}
  88. set {
  89. if (value == null)
  90. throw new ArgumentNullException ("counterName");
  91. counterName = value;
  92. }
  93. }
  94. // // may throw InvalidOperationException
  95. // [MonoTODO]
  96. // public PerformanceCounterType CounterType {
  97. // get {return 0;}
  98. // }
  99. //
  100. public string InstanceName {
  101. get {return instanceName;}
  102. set {instanceName = value;}
  103. }
  104. // // may throw ArgumentException if machine name format is wrong
  105. // [MonoTODO("What's the machine name format?")]
  106. // public string MachineName {
  107. // get {return machineName;}
  108. // set {machineName = value;}
  109. // }
  110. //
  111. // // may throw InvalidOperationException, Win32Exception
  112. // [MonoTODO]
  113. // public long RawValue {
  114. // get {return 0;}
  115. // set {
  116. // throw new NotImplementedException ();
  117. // }
  118. // }
  119. //
  120. // public bool ReadOnly {
  121. // get {return readOnly;}
  122. // set {readOnly = value;}
  123. // }
  124. //
  125. [MonoTODO]
  126. public void BeginInit ()
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. // [MonoTODO]
  131. // public void Close ()
  132. // {
  133. // throw new NotImplementedException ();
  134. // }
  135. //
  136. // [MonoTODO]
  137. // public static void CloseSharedResources ()
  138. // {
  139. // throw new NotImplementedException ();
  140. // }
  141. //
  142. // // may throw InvalidOperationException, Win32Exception
  143. // [MonoTODO]
  144. // public long Decrement ()
  145. // {
  146. // throw new NotImplementedException ();
  147. // }
  148. //
  149. // [MonoTODO]
  150. // protected override void Dispose (bool disposing)
  151. // {
  152. // throw new NotImplementedException ();
  153. // }
  154. //
  155. [MonoTODO]
  156. public void EndInit ()
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. // // may throw InvalidOperationException, Win32Exception
  161. // [MonoTODO]
  162. // public long Increment ()
  163. // {
  164. // throw new NotImplementedException ();
  165. // }
  166. //
  167. // // may throw InvalidOperationException, Win32Exception
  168. // [MonoTODO]
  169. // public long IncrementBy (long value)
  170. // {
  171. // throw new NotImplementedException ();
  172. // }
  173. //
  174. // // may throw InvalidOperationException, Win32Exception
  175. // [MonoTODO]
  176. // public CounterSample NextSample ()
  177. // {
  178. // throw new NotImplementedException ();
  179. // }
  180. //
  181. // // may throw InvalidOperationException, Win32Exception
  182. // [MonoTODO]
  183. // public float NextValue ()
  184. // {
  185. // throw new NotImplementedException ();
  186. // }
  187. //
  188. // // may throw InvalidOperationException, Win32Exception
  189. // [MonoTODO]
  190. // public void RemoveInstance ()
  191. // {
  192. // throw new NotImplementedException ();
  193. // }
  194. }
  195. }