I have a main thread (e.g. MainThread) that runs through a list of files to FTP/Copy/Email somewhere. I then have another thread that is called from within MainThread to send the files one at a time (e.g. SubThread).
My issue is this: when the SubThread thread is running (from within the first thread), how come MainThread.Running = False? Is MainThread not really running?
I have a workaround by using: not MainThread.NotRunning
For coordinating multiple threads I would use some dedicated flags protected by Critical Sections.
Enter(), Set value, Leave(); Enter(), Read value, Leave().
There seems to be a misconception. Methods can run within a Thread, but Threads run independently of each other no matter where they were initiated from, so one thread does not run “within” another thread, ever.
[quote]There seems to be a misconception. Methods can run within a Thread, but Threads run independently of each other no matter where they were initiated from, so one thread does not run “within” another thread, ever.
[/quote]
I agree. But if the MainThread is spinning around internally, waiting for the SubThread to finish, I would have thought it would still be set as MainThread.Running. I will change my code to check if MainThread.Running or MainThread.Waiting then