@Zax:
Assuming nothing else is going on (i.e. no messages are sent during the wait) then yes they will do the same thing.
However, you will not see quite the same result if a message is handled in that 100ms window which also calls wait:
This code will cause 'the date' to populate field 1 after 1 second - not 100 milliseconds.
Code: Select all
on myProcess
send "imitateWaitingButtonPress" to me in 50 milliseconds
wait 100 milliseconds with messages
put the date into fld 1
end myProcess
on imitateWaitingButtonPress
wait 1s with messages
end imitateWaitingButtonPress
This code will cause 'the date' to populate field 1 after 100 milliseconds:
Code: Select all
on myProcess_A
send "imitateWaitingButtonPress" to me in 50 milliseconds
send "myProcess_B" to me in 100 milliseconds
end myProcess_A
on myProcess_B
put the date into fld 1
end myProcess_B
on imitateWaitingButtonPress
wait 1s with messages
end imitateWaitingButtonPress
The reason is that waiting is recursive.
In the myProcess handler the 'wait' has to finish before the 'put' will execute - and wait only finishes when all handlers which have been called while the wait is happening (due to messages being handled) have finished.
In the myProcess_A handler - there is no (recursive) wait - so myProcess_A finishes as soon as the second send is done. Then the imitateWaitingButtonPress message will fire, and it will wait - but because that wait is with messages the myProcess_B pending message will still be handled at the expected time - just 'inside' the wait 1s.