StrataFrame Forum

Few questions about threads and waitwindow

http://forum.strataframe.net/Topic9847.aspx

By Robin J Giltner - 6/29/2007

I need to invoke the vb threading gods of the forum.  I'm very new to delegates and cross form method calls etc.

I have a main form with a class level WaitWindow that methods on the form can show, hide, update whatever.  This form makes several calls to a class that performs a lot of data manipulation.  Some of these take a long time, so I decided updating the WaitWindow would be nice to let the user know something is going on.

My declaration of the WaitWindow on the form.

Public WithEvents loWaitWindow As New MicroFour.StrataFrame.Messaging.WaitWindow

Here is my method to Update that WaitWindow

Public Sub UpdateWaitWindow(ByVal lcMessage As String)

'-- Update the Wait Window Message

Me.loWaitwindow.Message = lcMessage

End Sub

And on my class that does the data manipulation, I added this delegate

Public Delegate Sub UpdateWaitWindow(ByVal lcMessage As String)

And I added a Reference to the main Form to call UpdateWaitWindow on

Public Shared loForm As frmProjectMain = CType(Application.OpenForms("frmProjectMain"), frmProjectMain)

Now should I be able to call this UpdateWaitWindow by simply ?

loForm.Invoke(New UpdateWaitWindow(AddressOf loForm.UpdateWaitWindow), "new message")

By Greg McGuffey - 6/29/2007

I need to invoke the vb threading gods of the forum.




Well, that leaves me out, even though I do own a sewing machine and I'm not afraid to use it! Tongue



Sorry for the unhelpful reply...it's been a hard week, it's friday, I've been up way too long and it's summer time, and silliness just bubble to the fore. Hehe



I'll be watching the thread (er...no pun intended) to learn more about threads though!
By StrataFrame Team - 7/2/2007

Yes, that's how you would do it.  Now, when you're calling the Invoke of the ISynchronizeInvoke interface (on any Control object, like a form), you have to make sure that the control's thread is not busy.  Meaning, if you try to Invoke() from the main thread back to the main thread, you'll enter deadlock... the CLR waits until the main thread is not busy before calling the invoked method.
By Robin J Giltner - 7/2/2007

Great.  Thanks Ben.

Robin Giltner