Okay so I've read all the posts about threads and how to get them to work but the little blighters just won't work for me. In random threads the vars, lists or tables would be blank and/or store blank data to the DB. I have a bot that follows the following flow:
- I set the bot to run a schedule that runs a define
- The define connects to a sqlite DB and gets a list of tasks to perform
- Each task is a define that contains a thread in a new browser
- Each define contains var, lists and tables
So the multi-threading veterans out there are thinking... Duh, the lists and tables are not thread safe and are getting overwritten if the define gets run more than once at the same time. I did consider this, so I moved all the list and table work into a thread safe container provided by the TinyMCE (Open.Framework.dll).
Sadly this didn't work either, threads continued to fail due to blank vars, lists or tables. So I decided to make my own version of threading, I set a global variable for each thread to say if it was in use or not. That way a specific define could only be run once at one time. You guessed it... It didn't work. Over the space of time the bot would end out not running any tasks because it wouldn't 'unlock' the current define for some reason.
Any help would be great, also how does the Scheduler impact all this? Say the scheduler runs the letsgo() define every 3 minutes and the letsgo() define runs another define that contains a thread that takes 10 minutes to run. I presume the threadded define continues to run regardless of the scheduler kicking off the letsgo() define again?