[.net] Thread start and passing ref variables

Started by
9 comments, last by Numsgil 16 years ago
Quote:Original post by Mike.Popoloski
Oh, I guess I wasn't entirely clear there. If you want return values or ref/out parameter results, you need to call EndInvoke, which will have your ref parameters for you.

This may seem like a pain, but you can supply a method to BeginInvoke (the second to last parameter) that gets called whenever the method completes. When this event fires, you can use the provided IAsyncResult to extract the delegate, call EndInvoke, and retrieve your parameters.

If you need some source code on this, I can whip some up when I get home later today.


Ah okay. But I won't have those original ref values on hand if I use the async callback. Sounds like I'd have to call something like isDone(ref results) from VB, and have it call EndInvoke if the thread is done and retrieve the values. Which I guess is fine, it's functionally equivalent to a done flag.
[size=2]Darwinbots - [size=2]Artificial life simulation

This topic is closed to new replies.

Advertisement