Updated by Jiale:
This is the code with added Progress Controls. It works fine.
var t1 = Task.Run(() => CheckNC(progress, statusNC));
var t2 = Task.Run(() => CheckNL(progress, statusNL));
var t3 = Task.Run(() => CheckAD(progress, statusAD, token));
var t4 = Task.Run(() => CheckAC(progress, statusAC, token));
// Wait till all tasks are complete
await Task.WhenAll(t1, t2, t3, t4);
your Tasks all return void, so there is no result, just that they completed. only Task<> has a result.
Task<> example:
var t1 = new Task<int>(() => 10);
var t2 = new Task<string>(() => "hi");
t1.Start();
t2.Start();
await Task.WhenAll(t1, t2);
Console.WriteLine(t1.Result);
Console.WriteLine(t2.Result);
}
Task<> example with common result type:
var t1 = new Task<int>(() => 10);
var t2 = new Task<int>(() => 20);
t1.Start();
t2.Start();
var list = await Task.WhenAll(t1, t2);
foreach (var i in list)
Console.WriteLine(i);
or simpler syntax:
var list = await Task.WhenAll(
Task.Run(() => 10),
Task.Run(() => 20)
);
foreach (var i in list)
Console.WriteLine(i);