Private i As Integer = 0
Private IsMouseDown As Boolean = False
Private Delegate Sub SetTextDelegate(ByVal value As Integer)
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
IsMouseDown = True
Dim ThrdWhileDown As New Threading.Thread(AddressOf WhileMouseDown)
ThrdWhileDown.Start()
End Sub
Private Sub WhileMouseDown()
While IsMouseDown
i += 1
SetText(i)
End While
End Sub
Private Sub SetText(ByVal value As Integer)
If Me.InvokeRequired Then
Me.Invoke(New SetTextDelegate(AddressOf SetText), value)
Else
Me.Text = value.ToString
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
IsMouseDown = False
End Sub