I try to use my processor usage every second. I have a code setup for this, so no problem. I am trying to present this information in a line chart. I am using wpf toolkit. I intend to have a chart a bit like the image below. y axis containing seconds, x axis containing processor utilization.
Thus, its use of seconds and processor is constantly updated on the chart. (I would like some advice on the best way to present the use of my processor in a diagram, if this is not a very good method.)

I'm trying to find a way to set up my Timer dispatcher, which goes blank every second to update on the y axis.
This is what my current chart looks like.

, , , . , pointcollection, timer.tick(dispatchtimer).
:
<chartingToolkit:Chart Canvas.Left="25" Canvas.Top="307" Title="CPU Usage">
<chartingToolkit:Chart.DataContext>
<PointCollection>1,10 2,20 3,30 4,40</PointCollection>
</chartingToolkit:Chart.DataContext>
<chartingToolkit:LineSeries DependentValuePath="X" IndependentValuePath="Y" ItemsSource="{Binding}" Title="Cpu Usage">
<chartingToolkit:LineSeries.Background>
<RadialGradientBrush Center="0.075,0.015" GradientOrigin="-0.1,-0.1" RadiusY="0.9" RadiusX="1.05">
<GradientStop Color="#FFA9A3BD"/>
<GradientStop Color="#FF6C5B2C" Offset="1"/>
</RadialGradientBrush>
</chartingToolkit:LineSeries.Background>
</chartingToolkit:LineSeries>
</chartingToolkit:Chart>
, , , , . . , ( ), . . .
:
class Monitor
{
Stats stats = new Stats();
public delegate void CPUEventHandler(object sender, CPUEventArgs args);
public event CPUEventHandler CPUEvent;
DispatcherTimer timer = new DispatcherTimer();
private static double cpuCurrent;
public Monitor()
{
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += TimeChanged;
timer.Start();
}
void TriggerCPUEvent(CPUEventArgs args)
{
if (CPUEvent != null)
{
CPUEvent(this, args);
}
}
public void TimeChanged(object sender, EventArgs e)
{
cpuCurrent = stats.GetCurrentCpuUsage();
TriggerCPUEvent(new CPUEventArgs(cpuCurrent));
}
}
class Stats
{
private PerformanceCounter cpuCounter;
public Stats()
{
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
}
public float GetCurrentCpuUsage()
{
return cpuCounter.NextValue();
}
}