Ex2Task3_TaskIsCompleted();
... }
Visual Basic Sub Main(ByVal args() As String) ... ' Methods to call Ex2Task3_TaskIsCompleted() ... End Sub
2. Add the Ex2Task3_TaskIsCompleted() method to Program.cs (C#) or Module1.vb (Visual Basic): (Code Snippet – Intro to Parallel Extensions Lab - Ex2 Ex2Task3_TaskIsCompleted CSharp) C# Private static void Ex2Task3_TaskIsCompleted() { Task task1 = Task.Factory.StartNew(delegate { PayrollServices.GetPayrollDeduction(employeeData[0]); }); while (!task1.IsCompleted) { Thread.Sleep(1000); Console.WriteLine("Waiting on task 1"); } Task task2 = Task.Factory.StartNew(delegate { PayrollServices.GetPayrollDeduction(employeeData[1]); }); while (!task2.IsCompleted) { Thread.Sleep(1000); Console.WriteLine("Waiting on task 2"); } Task task3 = Task.Factory.StartNew(delegate { PayrollServices.GetPayrollDeduction(employeeData[2]); }); while (!task3.IsCompleted) { Thread.Sleep(1000); Console.WriteLine("Waiting on task 3"); } }
(Code Snippet – Intro to Parallel Extensions Lab - Ex2 Ex2Task3_TaskIsCompleted VB) Visual Basic Private Sub Ex2Task3_TaskIsCompleted() Dim task1 As Task = Task.Factory.StartNew(Sub() PayrollServices.GetPayrollDeduction(employeeData(0))) Do While Not task1.IsCompleted Thread.Sleep(1000) Console.WriteLine("Waiting on task 1") Loop Dim task2 As Task = Task.Factory.StartNew(Sub() PayrollServices.GetPayrollDeduction(employeeData(1)))
|