I have had a few people ask me about using the RadChart in the same manner as Performance Monitor (aka PerfMon). If you are not familiar with PerfMon, it is a tool that has been provided with Microsoft Windows for quite some time. You can open PerfMon by clicking the Start button within Windows, typing “perfmon” in the search box and pressing Enter. PerfMon is a simple utility that displays performance counters.  There are a wide variety of counters available, from CPU utilization of process threads to how many times the .NET Garbage Collector has run. The counters PerfMon allows you to monitor can also be accessed via the .NET framework. Actually, you can create your own custom performance counters for your applications as well, but that is not what this post is about. Essentially the desire being expressed is the ability to use RadChart display running data.

image

Before I go any further, I would like to point out that the RadChart is not necessarily built to present data in a real time scenario. That being said, it does not mean you cannot accomplish the task with RadChart. Essentially the RadChart is made up of a collection of Series which allow you to add Items to represent a value on the chart.  I figured what better way to show that you can use the RadChart to display running data like PerfMon than to show the same information as PerfMon. So I am running a Dual Core Intel processor which allows me to monitor CPU 0, CPU 1 and/or the Total CPU performance counters. In the screenshot below, you will see three (3) entries in the legend and three(3) lines on the chart. These represent the Series portion of the RadChart that I just mentioned. The peaks and valleys of each line are Items which represent the values of the performance counters. 

  image

Since I am providing the sample project below, I will not go into the details of the code.  I would like to mention a couple of things that you might take into consideration if you plan to use the RadChart in this manner.

 

  1. The RadChart will accommodate all the Items added to a Series, so limit the number of items that are shown. You will see in my code that I keep the number of items to twenty (20). This allows it to appear more like a running process and not get too compacted.
  2. This is a quick example, so I am using a timer. I would recommend you do your work asynchronously to avoid any impact on the UI. Something as simple as the BackgroundWorker component would be enough to separate your processing from the UI thread. 
  3. Again the RadChart is not designed for a real time scenario, so determine how many Series you expect to have at once and ensure that update intervals are optimized for the best performance.
  4. Finally, when you add a Series to the chart, you will want to add some defaulted Items so that all your Series lines are at the same point on the chart. This is not required, but your Series will be behind the others if you don’t do this. (See example below.)

image

The example application provided below is a rough version and does not necessarily represent optimal coding practices

RadChartAsPerformanceMonitor.zip


Related Posts

Comments

Comments are disabled in preview mode.