Multi-Threading
 
 
MetalWarrior  

Anyone know how I can call a function or subroutine, but then proceed with the code in the current sub without having to wait for the function to finish and return? For instance, suppose I wanted to run several Do...Loops at once, for an MDI application. Can't I set one going, then go on and start the next? It won't let me on to the next line of code until the first Do...Loop finishes, but I want them to run simultaneously.

Any ideas?



 
black eyez  

Sadly, VB will not let this happen  This would need multithreading, which is not supported by VB. You can only do this kind of thing in C++...

david goodlad
  - aka black eyez
    webmaster: the black hole



 
ian

Two methods come to mind for doing this:
1. Create a routine, where you activate a timer, and immediately exit the routine. The timer event would then begin the requested loop, perhaps specified by a global flag.

2. Create an out-of-process component server (ActiveX EXE), which returns objects you have designed to handle your Loop processing. Create this component, and select either thread-per-object, which allows objects created by the server to run on their own thread, or assign the desired number of threads to the threading pool, to which objects wil be distributed.

If you use any of the options under #2, then objects must be created using the CreateObject function, else they are assigned to the thread of the client process.



 
black eyez  

Hmm hey that's a good idea with the Activex objects  I try to stay away from all MS's "new technologies" type things, like all their rapid-app development stuff etc... I haven't looked at activex much because of that, but it sounds like it would work quite well!

david goodlad
  - aka black eyez
    webmaster: the black hole