@vcsjones has to be right. You don't see the result because program ended and window was closed.
I've tried your code and if I run the program from cmd, without debugger I can see the correct output. To make it a little more meaningful I've added another Console.WriteLine at the end of Main method:
for (int i = 0; i < 5; i++) { // var testClient = Task.Factory.StartNew( () => { TaskClient(); }); } Console.WriteLine("End of program execution.");
Returns:
End of program execution. -------------------- -------------------- -------------------- -------------------- --------------------
As you can see, it works just fine.
If you want to wait with further execution untill all tasks are done, you can use Task.WaitAll static method:
var tasks = new Task[5]; for (int i = 0; i < 5; i++) { // var testClient = tasks[i] = Task.Factory.StartNew( () => { TaskClient(); }); } Task.WaitAll(tasks);