End Sub. 3. Build and run the application.
3. Build and run the application. 4. You should observe that Tasks two and three do not start until the previous Task’s IsCompleted property is true. Figure 10 Output from running tasks in parallel and utilizing the IsCompleted property
Task 4 – Using the ContinueWith() Method While the IsCompleted property is useful for polling a Task to see if it is finished in order to be able to fire off more work, the Task class offers an even more convenient option. Using the ContinueWith() method makes it easy to string tasks together to run in a specific order. The functionality passed in as arguments to the ContinueWith() method will be executed once the Task object’s logic continues. 1. Replace the current method calls from Main(), with a call to Ex2Task4_ContinueWith(). C# static void Main(string[] args) { ... // Methods to call
|