Hello i'm having trouble trying to solve the cross thread.
If i use in Form_Load : CheckForIllegalCrossThreadCalls = False then it works, if i remove this then code not works. Any ideas?
Private Sub LoadCPURAM() 'Fix for CheckForIllegalCrossThreadCalls = False
Try
Dim CurrentRamUsage As Integer = SystemWatcher.TotalRam() - SystemWatcher.CurentPcRamUsage()
'Start Global CPU & Memory
PCResorcePbarRAM.Maximum = SystemWatcher.TotalRam()
PCResorcePbarRAM.Value = CurrentRamUsage
PCResorcePbarCPU.Value = SystemWatcher.MachineCpuUtilization()
Dim xy = String.Format("{0} MB", Math.Round(My.Computer.Info.TotalPhysicalMemory / (1024 * 1024)), 2).ToString 'ok
Dim qq As String = String.Format("{0} MB", CurrentRamUsage).ToString.Replace(".", "") 'ok
LabelRAMUsage.Text = qq + " / " + xy 'ok
LabelCPUUsage.Text = String.Format("{0} %", SystemWatcher.MachineCpuUtilization()).ToString
'Start World Server CPU & Memory
PCWorldPbarRAM.Maximum = CurrentRamUsage
PCWorldPbarRAM.Value = SystemWatcher.ApplicationRamUsage("worldserver")
PCWorldPbarCPU.Value = SystemWatcher.ApplicationCPUUsage("worldserver")
Dim aa = String.Format("{0} MB", Math.Round(My.Computer.Info.TotalPhysicalMemory / (1024 * 1024)), 2).ToString 'ok
Dim bb As String = String.Format("{0} MB", SystemWatcher.ApplicationRamUsage("worldserver")).ToString.Replace(".", "") 'ok
LabelWorldRAMUsage.Text = bb + " / " + aa 'ok
LabelWorldCPUUsage.Text = String.Format("{0} %", SystemWatcher.ApplicationCPUUsage("worldserver")).ToString
'Start Auth Server CPU & Memory
PCLoginPbarRAM.Maximum = CurrentRamUsage
PCLoginPbarRAM.Value = SystemWatcher.ApplicationRamUsage("authserver")
PCLoginPbarCPU.Value = SystemWatcher.ApplicationCPUUsage("authserver")
Dim cc = String.Format("{0} MB", Math.Round(My.Computer.Info.TotalPhysicalMemory / (1024 * 1024)), 2).ToString 'ok
Dim dd As String = String.Format("{0} MB", SystemWatcher.ApplicationRamUsage("authserver")).ToString.Replace(".", "") 'ok
LabelAuthRAMUsage.Text = dd + " / " + cc 'ok
LabelAuthCPUUsage.Text = String.Format("{0} %", SystemWatcher.ApplicationCPUUsage("authserver")).ToString
Catch ex As Exception
Data.Message = ex.Message
End Try
End Sub
Private Sub TimerWacher_Tick(sender As Object, e As EventArgs) Handles TimerWacher.Tick
Try
Dim PCResorceUsageThread As New Thread(AddressOf LoadCPURAM)
PCResorceUsageThread.Start()
Catch ex As Exception
Data.Message = ex.Message
End Try
End Sub