How can you switch between processes based on time?
++++
I have an Excel macro sending XML requests to Google, it has 3 important processes.
- The process sending the XML requests. This process is limited to 10 requests per second.
- A loading bar with the ability to quit the program
- The Excel Application itself (it should be editable while the program is running)
The macro is currently using the sleep function (from kernel32.dll) to delay the processes, and the DoEvents function to make sure both process are run (and so the application can be modified in the background).
Ex. Process 1
Do While True
Call doSomething
DoEvents 'handles processes 2 and 3
Sleep 100
Loop
This method delays the entire application. Editing the Excel Worksheet in the background is laggy because of the 100ms delay, and attempting to quit the program is also delayed.
To remove this lag, I would like processes 2 and 3 to be running and switch control to process 1 when it is time to send a request. After the request is sent, process 1 can give control of the program back to processes 2 and 3. Does anyone have a solution to this?
Bonus: VBA seems to have little capability for multi threading/processing, but if anyone can think of a way to run all these processes at once I'd love to know about it