Jump to content

Proceed to 2nd loop while 1st loop is still running


liren
 Share

Recommended Posts

As mentioned in the title, I'm still in the progress of learning and recently I came across this problem but couldn't find a proper way to solve it.

I have 2 loops of command running, so it is sort of like:

while 1=1
<command lines 1>
wend

while 1=1
<command lines 2>
wend

obviously there is no way it would proceed to <command lines 2> as it will only keep on repeating the first loop.

so what command can i use to make both line 1 & 2 to be running at the same time? or is there any other approach?

Edited by liren
Link to comment
Share on other sites

Create something like this:

while 1
    <command lines 1> 
    <command lines 2>
wend

but I need both <command lines 1> and <command lines 2> to be running at the same time, and they both needs infinite repetition.

by doing like what you said, command lines 2 come only after command lines 1 end.

Edited by liren
Link to comment
Share on other sites

It appears to me that you want to call each loop in its own thread, and AFAIK AutoIt doesn't do multi-threading. You could place each loop in its own AutoIt program and then run them both from a third AutoIt program via the Run function or the ShellExecute function (I'm still not clear on their differences yet!). As you can tell, I'm still learning though, so please take my suggestions with a grain of salt.

Edited by Fubarable
Link to comment
Share on other sites

It appears to me that you want to call each loop in its own thread, and AFAIK AutoIt doesn't do multi-threading. You could place each loop in its own AutoIt program and then run them both from a third AutoIt program via the Run function or the ShellExecute function (I'm still not clear on their differences yet!). As you can tell, I'm still learning though, so please take my suggestions with a grain of salt.

Afaik ShellExecute is like double clicking a file in explorer. It can be used to run non-executables using their default application. For executables I don't think it makes much difference.

@Liren. There is usually little need for true multi threading. After all, computers didn't always have multi-cores, or hyperthreading.

If one of your functions takes too long to return you can use AdlibRegister on the fast function to quickly call it while the other function is running. In this case the slow function gets halted for the duration it takes the fast function to return. This doesn't interrupt AutoIt build-in functions though.

If both your functions take a long time to end it might be best to break them up into smaller, faster functions and weave them together in one while loop.

If your functions cannot be broken up for some reason (I recently saw a topic about DirCopy taking a long time to return for instance) you can think about running it in another process (two, or more autoit scripts working together).

You might want to share your code so others can think of the best solution for your script.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...