Tuesday, January 16, 2018

Updating data on the screen when utilizing threads

    Delegate Sub StringParameterDelegate(ByVal value As String)

    Private Sub UpdateTimerTickedLabel(ByVal value As String)
        If InvokeRequired Then
            ' We're not in the UI thread, so we need to call BeginInvoke
            BeginInvoke(New StringParameterDelegate(AddressOf UpdateTimerTickedLabel), New Object() {value})
            Return
        End If
        ' Must be on the UI thread if we've got this far
        lblTimerTicked.Text = value
    End Sub