InvokeRequired not working with my Timer

M

Mark Denardo

Hey all, I'm having a problem with the following:

Private m_myDELEGATE As New myDELEGATE(AddressOf
ReceivingServerMessage_UIThread)
Delegate Sub myDELEGATE(ByVal ReceivingServerMessage As NetworkMessage)

Public Sub ReceivingServerMessage(ByVal objNetworkMessage As NetworkMessage)
If (Me.InvokeRequired) Then
Dim args() As Object = {objNetworkMessage}
Me.Invoke(m_myDELEGATE, args)
Else
ReceivingServerMessage_UIThread(objNetworkMessage)
End If
End Sub

Basically I use this method to pass control from a worker thread back to the
UI Thread. It works fine if its a normal thread, but when I use a timer and
call this method after the timer elapses, then Me.InvokeRequired = False and
it treats it likes its already on the main thread, and thus when I get in
ReceivingServerMessage_UIThread, I'm getting the all to familiar
"Cross-Thread operation not valid" error.

I thought Timers were just special cases of threads. What is going on
and/or what do I need to do to correct my problem?
 
M

Mark Denardo

Sorry I jumped the gun...my thread is also making Me.InvokeRequired return
False. It must be something else I changed. I'll have to investigate more.

Sorry Disregard....for now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top