Consider a scenario where you have defined and started multiple tasks. For instance, imagine you are downloading multiple items from the web in order to process them and build some UI elements for the user.
Assume you started a task for each item and you stored the references in an array (the TArray<ITask> type). You may decide to wait for the completion of all items before proceeding to process them or start processing items as soon as one of them is available.
Two methods are available to handle both cases:
- The TTask.WaitForAll method: It will accept the array of ITask references as an argument and will synchronously wait until all of them have been completed. A second optional argument is available to set a timeout for the wait, and all considerations are made in the previous section about waiting synchronously or asynchronously standing.
- The TTask.WaitForAny method: It has identical arguments but will return as soon as one of the items...