Wait method Waits
the current operation started with the Start
or Execute method to
complete.
Syntax:
variable = object.Wait(timeout)
Arguments
Return value - Boolean. If the operation completed in the
allowed timeout period the returned value is True, if the operation
is not completed within the allowed timeout period the returned
value is False.
timeout - Positive integer. The allowed timeout in
milliseconds. The method will wait the specified number of
milliseconds the operation to complete. After that if the operation
is not complete yet the method returns False.
Examples:
Remarks:
Compared to the Busy
property the Wait method is the same but with a timeout. So, the Busy
property just checks if the operation is complete and returns
immediately. while the Wait method can be instructed to wait the
completetion the specified time.
Thus the Wait method is intended mostly for the points in the
application where the application needs the results of the thread work
in order to continue its work. So the application specifies a
reasonable timeout period and waits the thread to catch up. Anyway the
application should be able to deal with negative result - i.e. the
work is not done in the specified timeout. What to do in such a case
depends on the application structure. For example in ASP application
you can tell the user that the server is too busy and the operation
will take more time than expected and provide another page where the
user will be able to continue (wait more). In non-ASP application with
linear execution (such as Windows Scripting Host for example) the main
script (the application) will most likely need the results right at
this moment. So the timeout should be a bit bigger and if the
operation is still incomplete then the only possible actions will be
optional (by user request) additional waiting or error message.
On contrary the Busy property can be used when the results are not
so important. For example in an application where the user does
something else and besides that wants to see if the background task is
complete.
Applies to: COMScriptThread
object
|