Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delegates sometimes do not seem to work in their own threads.

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
US
I can see no rhyme or reason for it, but sometimes my delegates do not seem to run in their own threads. I'm using them mainly to process data while allowing my form to continue to update (in other words rather than using DoEvents through all my code). Sometimes this seems to work fine and others it doesn't. I usually do it one of two ways and it works/will not work both ways.

1) If the sub/function to run to is in the forms class I create the delegate right there.

Code:
<various code> ...
        Dim delObj(1) As Object
        delObj(0) = "This is the number "
        delObj(1) = 1

        Dim del As New delThisFunction(AddressOf ThisFunction)
        del.DynamicInvoke(delObj)
... <various code>

2) If the sub/function to run is in another class/module I create a function I call from the form and in that function it creates the delegate.

Code:
<various code> ...
        CallDel("This is the number ", 1)
... <various code>

Public Sub CallDel(ByVal text As String, number As Integer)
        Dim delObj(1) As Object
        delObj(0) = "This is the number "
        delObj(1) = 1

        Dim del As New delThisFunction(AddressOf ThisFunction)
        del.DynamicInvoke(delObj)
End Sub

Same code just started at two different places. Though like I said one doesn't seem to work any more frequently than the other. It seems to happen no matter if it is a sub or function. Whether it is in a class or module. I've got to be missing something though. Some pattern that it is actually following though it doesn't seem to. I know this all ends up sounding rather vague, but any ideas?

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top