({{, WaitAsynchronousTask[task] 
waits for task to complete.}})

OpenersNotesSection(Spacer1)Details and Options

task is an (RefLink[AsynchronousTaskObject, paclet:ref/AsynchronousTaskObject]) expression.

WaitAsynchronousTask waits until task completes.

The following option can be given:

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Starting an asynchronous task and waiting until it completes is equivalent to running the task synchronously:

task=URLFetchAsynchronous["http://exampledata.wolfram.com/5mb.dat",
If[#2==="data",MessageDialog["Download complete."]]&]
WaitAsynchronousTask[task]

OpenersExampleSection1(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)"Timeout"  (1)

Wait for an asynchronous task to complete and then continue, even if it is not done:

done=False;
Print["Starting download at ",DateString[]];
task=URLFetchAsynchronous["http://exampledata.wolfram.com/20mb.dat",
If[#2==="data",done=True;MessageDialog["Download complete."]]&];
WaitAsynchronousTask[task,"Timeout"->1.5]
If[!done,Print["Still downloading at ",DateString[]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}})}})