Unity - Using Async Await with Task.ContinueWith
Task.ContinueWith Method (System.Threading.Tasks)
Task.ContinueWith is a method in C# that lets you specify a task (or set of tasks) to execute after a particular task completes.
The continuation task is passed to the ContinueWith method as a lambda expression.
For example, if you have a task called firstTask and want to run secondTask after firstTask completes, you can use the following code:
firstTask.ContinueWith((antecedent) => secondTask());
The lambda expression passed to ContinueWith takes an antecedent argument, which represents the preceding task.
You can also chain multiple tasks together by calling ContinueWith on the result of a previous ContinueWith call.
For example:
firstTask.ContinueWith((antecedent) => secondTask()).ContinueWith((antecedent) => thirdTask())
You can also use Task.WhenAll or Task.WhenAny to wait for multiple tasks to complete, or wait for any one of several tasks to finish.