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.
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.
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.
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.