Few questions about threads and waitwindow


Author
Message
Robin J Giltner
Robin J Giltner
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 105, Visits: 650
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")


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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!
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
Robin J Giltner
Robin J Giltner
StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)StrataFrame User (179 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Great.  Thanks Ben.

Robin Giltner

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search