Imports System.Windows.Forms.DataVisualization.Charting Public Class Form1 Private pcs As Dictionary(Of String, PerformanceCounter) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 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 String, PerformanceCounter)() For p = 0 To Environment.ProcessorCount - 1 Dim key As String = "CPU " & p.ToString() pcs.Add(key, New PerformanceCounter("Processor", "% Processor Time", p.ToString())) Next Chart1.Series.Clear() For Each kv In pcs With Chart1.Series.Add(kv.Key) .ChartArea = Chart1.ChartAreas(0).Name .ChartType = SeriesChartType.Line For n = 1 To 100 .Points.Add(0.0) Next 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 With Chart1.Series(kv.Key).Points .RemoveAt(0) .Add(CDbl(kv.Value.NextValue())) End With Next End Sub End Class