You would have to go multithreaded for that. DoEvents does not take care of such things. It just stops executing your code at the current position to handle messages in your app's queue, after which it returns at the position it left off. There's no way that you can have a single thread executing two sections of code simultaneously.
You can put the function to be called in an out-of-proc COM server and have it executed asynchronous there. But since this function is being called in a loop, it might have to create much objects to be executed all at the same time.
Greetings,
Rick
VB is Single threaded and thus can only execute one stream of code at a time. As Lazyme points out one way around this is to create an out of process COM object and fudge it to be a async call and ,if you need it to, fire back an event when it is finished. Another way of doing this is to involve a message queing system like MSMQ which effectively does the same thing but without a lot of the tricks you need to do with vb. Depending on your requirements you may be able to right your functions in a conventional DLL in a language like C++ and using API's spawn another thread and call the function. The first method which Lazyme points out would have you potentially calling multiple instances of the same Object to cater for the fact that your loop may be running faster then the exterior method takes to do its job.
With out knowing more it is hard to say which you should choise
I see what you're saying about threading.
I've heard all different points saying VB can't support threading, VB can support threading, CreateThread works in VB 5.0 but not VB 6.0.
I guess I won't know until I test it myself.
I did find a link to a page on "Planet Source" which allows you to download a class that allows you to thread in VB 6.0 (So it says!).
I'm going to lose the LOOP and try threading to see what happens.
CreateThread worked fine in VB5, but was - theoretically - shackled in VB6. However, it actually works fine in VB6:
a) in the IDE (unless you try to debug the code, which has much the same effect as debugging a hook)
b) in compiled applications if you compile to P-code rather than to native code.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.