Shared x As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ctThread As Thread = New Thread(AddressOf r)
ctThread.IsBackground = True
ctThread.Start()
End Sub
Sub r()
Dim s As New a
x += 1
count()
s.str()
End Sub
Class a
Sub str()
Dim ctThread As Threading.Thread = New Threading.Thread(AddressOf d)
ctThread.Start()
End Sub
Sub d()
Thread.Sleep(2000)
x -= 1
Form1.count()
End Sub
End Class
Private Delegate Sub UpdateTextBox(ByVal recvData As String)
Sub count()
If Label1.InvokeRequired Then
Dim d As New UpdateTextBox(AddressOf count)
Me.BeginInvoke(d, x.ToString)
Else
Label1.Text = x
End If
End Sub