I have the following code:
Public Class Form1
Dim ping As New Ping
Dim replyeuw As PingReply
Dim euwthread As Thread
Dim num As Integer = 0
Dim pingms As Integer
Public Sub pingareuw()
If My.Computer.Network.IsAvailable Then
replyeuw = ping.Send("prod.euw1.lol.riotgames.com")
pingms = replyeuw.RoundtripTime
If replyeuw.Status = IPStatus.Success Then
FlatLabel3.Text = "EUW PING: " & pingms
Else
FlatLabel3.Text = "Nope..."
End If
Thread.Sleep(500)
Else
MsgBox("Liga a net pah!")
End If
End Sub
Private Sub FormSkin1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
euwthread = New Thread(AddressOf Me.pingareuw)
euwthread.Start()
End Sub
And I'm getting this error:
Cross-thread operation not valid: Control 'FlatLabel3' accessed from a thread other than the thread it was created on.
Why?