home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / pcwrite.aspx < prev    next >
Encoding:
Text File  |  2000-06-09  |  3.5 KB  |  83 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <h4>How Do I...Write to a performance counter?</h4>
  5.  
  6. <div class="indent" style="width:660"><font face="Tahoma" size="1">
  7.  
  8. <p>Windows performance counters allow
  9. your applications and components to publish, capture, and analyze the
  10. performance data that applications, services, and drivers provide. You can use
  11. this information to determine system bottlenecks and fine-tune system and
  12. application performance. For example, you might use a performance counter to
  13. track the number of orders processed per second or the number of users currently
  14. connected to the system. Using the NGWS runtime's <span class="Bold">PerformanceCounter</span>
  15. component, you can easily  create your own custom counters and publish
  16. performance data relevant to your application, such as those mentioned above.</p>
  17.  
  18. <p>This
  19. sample illustrates publishing (writing) simple performance information to a custom
  20. performance counter. It's a small console application that can be run from a
  21. command prompt. The application takes three command line arguments. The first is
  22. a performance object name (category). The second argument is the counter name.
  23. The third argument is the counter instance name.</p>
  24.  
  25. <p>For example, if you want to publish data about the total number of international
  26. orders for milk, try running the sample as follows:</p>
  27.  
  28.     </font><font face="Courier New" color="Blue" size="1"><blockquote>
  29.         > PCWrite.exe "Orders" "Milk Orders" "International"
  30.     </blockquote></font><font face="Tahoma" size="1">
  31.  
  32. <p>Now,
  33. wait for the application to display "Started" and run the PerfMon.exe.
  34. In PerfMon, click on the "add" toolbar button. A dialog will open.
  35. Select the "Orders" performance object, "Milk Orders"
  36. counter, and "International" instance. Click "Add", close
  37. the dialog, and observe that you can use the PCWrite sample to change the
  38. published value by pressing "+" or "-".</p>
  39.  
  40. <p>In its simplest form, writing to a custom performance counter involves:</p>
  41.  
  42. <ol>
  43. <li>Instantiating a PerformanceCounter component and pointing it to an appropriate
  44. performance counter:
  45.  
  46.     </font><font face="Courier New" color="Blue" size="1"><p>
  47.         PerformanceCounter counter; <br>
  48.         counter = new PerformanceCounter(objectName, counterName, instanceName);
  49.     </p></font><font face="Tahoma" size="1">
  50.  
  51. <li>Setting the RawValue property of the counter:
  52.  
  53.     </font><font face="Courier New" color="Blue" size="1"><p>
  54.         counter.RawValue = 50;
  55.     </p></font><font face="Tahoma" size="1">
  56.  
  57. </ol>
  58.  
  59. <p>Have a great time PerformanceCounter'ing!</p>
  60.  
  61. </font></div>
  62.  
  63. <h4>Example</h4>
  64.  
  65. <p>
  66. <div class="indent">
  67. <a target="_blank" href="/quickstart/howto/samples/Services/PerformanceCounters/PCWrite">
  68. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  69. </a>
  70. <div class="caption">PCWrite.exe</div><br>
  71. [<a target="_blank" href="/quickstart/howto/samples/Services/PerformanceCounters/PCWrite">View Sample</a>] | 
  72. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/PerformanceCounters/PCWrite/PCWrite.src">View Source</a>]<p>
  73. </div>
  74.  
  75. <h4>Source Code</h4>
  76.  
  77. <div class="code">
  78. <xmp>
  79. <!-- #include virtual="/quickstart/howto/samples/Services/PerformanceCounters/PCWrite/PCWrite.cs" -->
  80. </xmp>
  81. </div>
  82.  
  83. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->