每次我使用时:
form1.show()
我明白了Reference to a non-shared member requires an object reference.
它工作到现在。我不知道是什么问题。
此外,它甚至没有显示在“启动表单”下拉菜单中。
编辑:包括整个代码。
Private _cpuid As String
///Here is the generated constructor
Sub New()
' TODO: Complete member initialization
End Sub
Public ReadOnly Property cpuid As String
Get
Return _cpuid
End Get
End Property
Private _pc As PerformanceCounter
Private _currentvalue As Integer = 0
Public Sub New(ByVal cpuid As String)
InitializeComponent()
_cpuid = cpuid
_pc = New PerformanceCounter("Processes", "CPU Usage (%)", cpuid)
Me.ProgressBar1.Maximum = 100
Me.ProgressBar1.Minimum = 0
Me.Label1.Text = "CPU" & cpuid
End Sub
Public Sub callperformancecounter()
_currentvalue = CInt(_pc.NextValue())
Me.ProgressBar1.Value = _currentvalue
Me.label2.text = _currentvalue & " %"
End Sub