Me.Invoke in VB.NET doesn't actually "Invoke" - threads stall on Invoke statement

Posted by rwmnau on Stack Overflow See other posts from Stack Overflow or by rwmnau
Published on 2010-03-16T21:37:13Z Indexed on 2010/03/16 21:41 UTC
Read the original article Hit count: 307

Filed under:
|
|

I've got the following code:

Public Delegate Sub SetStatusBarTextDelegate(ByVal StatusText As String)
Private Sub SetStatusBarText(ByVal StatusText As String)
    If Me.InvokeRequired Then
        Me.Invoke(New SetStatusBarTextDelegate(AddressOf SetStatusBarText), StatusText)
    Else
        Me.labelScanningProgress.Text = StatusText
    End If
End Sub

The problem is that, when I call the "SetStatusBarText" sub from another thread, InvokeRequired is True (as it should be), but then my threads stall on the Me.Invoke statement - pausing execution shows them all just sitting there, not actually invoking anything.

Any thoughts about why the threads seem to be afraid of the Invoke?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about multithreading