Tech Off Post

Single Post Permalink

View Thread: I was told today to not worry cross-thread execution when...
  • User profile image

    I check inside the method to see if an invoke is required. If so have the delegate make a recursive call to the method, otherwise perform the action.

    This is in vb but should be clear.

     Public Sub ReadKeyboard()
            If Me.InvokeRequired Then
                Dim x As Action = AddressOf ReadKeyboard
                me.Text = "Keyboard acquired"
            End If
     End Sub

    Check out the invokerequired property of the control class.