IAMK Posted June 22, 2018 Share Posted June 22, 2018 I was wondering if it would be a good or bad idea to implement multithreading purely for the sake of polling? E.g. Thread1: Run script as normal. Thread2: Poll every 5 seconds for certain conditions, e.g. check processes opened, actions to execute. Currently, the way I have my scripts is messy. I have the same condition check functions called inside all my while loops to prevent infinite looping. Also, it would be nice to have 1 thread pause the other thread. Is that possible? E.g. If Thread2 finds that process1 is closed, it will pause Thread1 until process1 is opened again. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 22, 2018 Developers Share Posted June 22, 2018 if the check is simple and fast you could simply use the adlibxxx functions. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Bert Posted June 22, 2018 Share Posted June 22, 2018 You could have a sub loop of the main loop The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
RTFC Posted June 22, 2018 Share Posted June 22, 2018 (edited) You appear to be confusing processes and threads, i.e., multi-processing (easily done in AutoIt) versus multi-threading (not; see countless earlier discussions on AutoIt being single-threaded). Pausing and resuming processes is possible, and discussed in various forum topics (for example here and here). It is, incidentally (geek alert!), also possible in AutoIt to suspend/resume individual threads of another (multi-threaded) process (e.g., some dlls), but since AutoIt scripts are themselves single-threaded, that does not apply in this context (plus: here be dragons...). The two previous suggestions by Jos and Bert should work out fine for quick and simple tasks. If, however, multiple tasks are time-critical and must run alongside each other, I'd suggest writing two separate scripts (one launching and controlling the other), and having them communicate with IPC (inter-process communication, again, plenty of examples on the forum on that subject). BTW attempting to force AutoIt to run multi-threaded has been known to open interdimensional portals, releasing hell-spawn and brain-eating demons... I'd suggest you keep that door closed. Edited June 22, 2018 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now