Imports System.Windows.Forms.DataVisualization.Charting Public Class Form1 Private pcs As Dictionary(Of Integer, PerformanceCounter) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Shown Chart1.ChartAreas(0).AxisY.Maximum = 100.0 Chart1.ChartAreas(0).AxisY.Minimum = 0.0 Chart1.ChartAreas(0).AxisX.LabelStyle.Enabled = False pcs = New Dictionary(Of Integer, PerformanceCounter)() Chart1.Series.Clear() For p = 0 To Environment.ProcessorCount - 1 Dim key As String = "CPU " & p.ToString() pcs.Add(p, New PerformanceCounter("Processor", "% Processor Time", p.ToString())) With Chart1.Series.Add(key) .ChartArea = Chart1.ChartAreas(0).Name .ChartType = SeriesChartType.Column .Points.AddXY(key, 0.0F) End With Next DirectCast(TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit() TrackBar1.TickFrequency = 500 TrackBar1.SmallChange = 100 TrackBar1.LargeChange = 1000 TrackBar1.Minimum = 50 TrackBar1.Maximum = 2000 TrackBar1.Value = 500 Timer1.Interval = 500 TrackBar1.DataBindings.Add("Value", Timer1, "Interval", False, DataSourceUpdateMode.OnPropertyChanged) Label1.DataBindings.Add("Text", TrackBar1, "Value", True).FormatString = "0 ミリ秒間隔" DirectCast(TrackBar1, System.ComponentModel.ISupportInitialize).EndInit() Timer1.Start() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick For Each kv In pcs Dim key As String = "CPU " & kv.Key.ToString() Chart1.Series(key).Points(0).SetValueY(CDbl(kv.Value.NextValue())) Next Chart1.Invalidate() End Sub End Class