TaskWait[task]
waits for the specified task to be completely finished.
TaskWait
TaskWait[task]
waits for the specified task to be completely finished.
Details and Options
- task can be either a TaskObject or task identifier string for a specific task.
- TaskWait[task] blocks until task is completely finished, then returns the TaskObject[…] representing task.
- For a scheduled task, TaskWait[task] waits until all instances of the task specified in the schedule have been executed.
- The following option can be given:
-
TimeConstraint Infinity maximum time to wait before returning - TaskWait has attribute Listable.
Examples
open all close allBasic Examples (4)
Start a task in the current session and wait until it finishes:
TaskWait[
SessionSubmit[Integrate[x ^ 2 Log[x] ^ 5 / Sqrt[1 - x ^ 2], {x, 0, 1}],
HandlerFunctions -> <|"TaskFinished" -> MessageDialog|>, HandlerFunctionsKeys -> {"EvaluationExpression", "EvaluationResult"}]
]Wait for a task specified by its UUID:
obj = LocalSubmit[Pause[20]];uuid = obj["TaskUUID"]TaskWait[uuid]Start a task in a separate local kernel and wait until it finishes:
TaskWait[LocalSubmit[Integrate[x ^ 2 Log[x] ^ 5 / Sqrt[1 - x ^ 2], {x, 0, 1}],
HandlerFunctions -> <|"TaskFinished" -> MessageDialog|>, HandlerFunctionsKeys -> {"EvaluationExpression", "EvaluationResult"}]]Starting an asynchronous task and waiting until it completes is equivalent to running the task synchronously:
TaskWait[URLSubmit["http://www.wolfram.com", HandlerFunctions -> <|"TaskFinished" -> MessageDialog|>]]Options (1)
TimeConstraint (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 = URLSubmit["http://exampledata.wolfram.com/20mb.dat", HandlerFunctions -> <|
"BodyReceived" -> ((done = True;MessageDialog["Download complete."])&),
"BodyChunkReceived" -> (None&)|>];
TaskWait[task, TimeConstraint -> 1.5]Related Guides
History
Text
Wolfram Research (2017), TaskWait, Wolfram Language function, https://reference.wolfram.com/language/ref/TaskWait.html.
CMS
Wolfram Language. 2017. "TaskWait." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TaskWait.html.
APA
Wolfram Language. (2017). TaskWait. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TaskWait.html
BibTeX
@misc{reference.wolfram_2026_taskwait, author="Wolfram Research", title="{TaskWait}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/TaskWait.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_taskwait, organization={Wolfram Research}, title={TaskWait}, year={2017}, url={https://reference.wolfram.com/language/ref/TaskWait.html}, note=[Accessed: 15-June-2026]}