WaitNext
✖
WaitNext
Details

- The eidi are EvaluationObject expressions obtained by submitting expressions for concurrent evaluation using ParallelSubmit.
- WaitNext[{eid1,eid2,…}] returns a list {res,eid,eids}, where res is the result of the finished evaluation, eid is its EvaluationObject, and eids is the list of remaining evaluations.
- The last element in the list produced by WaitNext is suitable for another call to WaitNext.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Submit a number of integer factorizations:

https://wolfram.com/xid/0i1trmph2-i8liwy

Wait until the fastest one is done:

https://wolfram.com/xid/0i1trmph2-hxvzo7


https://wolfram.com/xid/0i1trmph2-dg8r3c

Finally, wait for all remaining ones:

https://wolfram.com/xid/0i1trmph2-cgq0hg

Scope (1)Survey of the scope of standard use cases
Define a symbol only on the master kernel:

https://wolfram.com/xid/0i1trmph2-6odhto
Submit a number of evaluations using this symbol:

https://wolfram.com/xid/0i1trmph2-o47gjt

https://wolfram.com/xid/0i1trmph2-qy1ll4

Return the next result, but wrap it in Hold first:

https://wolfram.com/xid/0i1trmph2-gjp4s3

Applications (1)Sample problems that can be solved with this function
Test for primality, returning $Failed if it is not prime:

https://wolfram.com/xid/0i1trmph2-d2vyth
Adaptively schedule search jobs until a result has been found or the computation is aborted:

https://wolfram.com/xid/0i1trmph2-cly25c

https://wolfram.com/xid/0i1trmph2-2iy37

Properties & Relations (2)Properties of the function, and connections to other functions
ParallelTry is essentially implemented in terms of WaitNext:

https://wolfram.com/xid/0i1trmph2-c22dap

https://wolfram.com/xid/0i1trmph2-ferohc

Scheduled evaluations no longer needed can be aborted with AbortKernels:

https://wolfram.com/xid/0i1trmph2-b1zabm


https://wolfram.com/xid/0i1trmph2-njwgfp


https://wolfram.com/xid/0i1trmph2-bn7sed
Possible Issues (2)Common pitfalls and unexpected behavior
No more than $KernelCount evaluations are initially run to find the fastest one:

https://wolfram.com/xid/0i1trmph2-bmgk95


https://wolfram.com/xid/0i1trmph2-czr68


https://wolfram.com/xid/0i1trmph2-5977r


https://wolfram.com/xid/0i1trmph2-cqbbmw

Each evaluation should be waited for exactly once:

https://wolfram.com/xid/0i1trmph2-dd9pc4


https://wolfram.com/xid/0i1trmph2-depdbi

One of the evaluation objects has already completed:

https://wolfram.com/xid/0i1trmph2-lkgklu


https://wolfram.com/xid/0i1trmph2-cw72xi

Wolfram Research (2008), WaitNext, Wolfram Language function, https://reference.wolfram.com/language/ref/WaitNext.html.
Text
Wolfram Research (2008), WaitNext, Wolfram Language function, https://reference.wolfram.com/language/ref/WaitNext.html.
Wolfram Research (2008), WaitNext, Wolfram Language function, https://reference.wolfram.com/language/ref/WaitNext.html.
CMS
Wolfram Language. 2008. "WaitNext." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WaitNext.html.
Wolfram Language. 2008. "WaitNext." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WaitNext.html.
APA
Wolfram Language. (2008). WaitNext. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WaitNext.html
Wolfram Language. (2008). WaitNext. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WaitNext.html
BibTeX
@misc{reference.wolfram_2025_waitnext, author="Wolfram Research", title="{WaitNext}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/WaitNext.html}", note=[Accessed: 01-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_waitnext, organization={Wolfram Research}, title={WaitNext}, year={2008}, url={https://reference.wolfram.com/language/ref/WaitNext.html}, note=[Accessed: 01-April-2025
]}