Bit tongue-in-cheek there, eh?
Here’s what I suggest you try (and this will work going back as well):
Subclass Thread and create a pair of Start/Stop methods which sets a boolean property named something like “isRunning as Boolean”. In the Run event of the thread have code like this:
if Not IsRunning then
.... Your Code Here....
That way the thread is always “running”, but only actually trying to do something when you want it to.
The other way to do this is to have the thread code simply look and see if there’s more data to be processed from some sort of queue. Perhaps an array of strings which you populate in the DataAvailable event with:
Then all you’d need to do in the run event is:
If ubound(DataQueue) = -1 then
Thanks. I think I can see how to use that. As it happens, I do get all the data there is and then feed it to the app in lines one by one. Only when there is none left or only a partial line do I do another read and suspend.
Meanwhile a bit more testing with my app, this time with just the one thread reading from remote. It’s now looking like an issue with CPU starvation for threads: largely, the main thread has been idle while I’ve been looking at what’s going on. In my most recent test, I forced the main thread to do some stuff, and every time I did, the other thread suddenly moved on rapidly for a short while before becoming comatose again. It eventually completed, correctly, the work it was expected to do. It just took 17 minutes instead of about two.
I’ve got case 45925 open for this issue.