I am reading Exam Ref 70-483: Programming in C# by Wouter de Kort.
The writer doesn't explicitly mention the version of C#, but I guess it's 5.0 since he makes heavy use of async/await keywords.
The examples in this book only use Thread.Sleep() and not Task.Delay()
Parallel.For(0, 10, i =>
{
Thread.Sleep(1000);
});
,
Task.Run(() =>
{
bag.Add(42);
Thread.Sleep(1000);
bag.Add(21);
});
etc etc...
From other reading/SO questions like this, I'd figure that
await Task.Delay(1000)
should generally do better in a parallel context than
Thread.Sleep(1000)
because Task.Delay leaves it's thread unhindered thus allowing other tasks execute on it.
I've just Ctrl-F'd the book and it didn't find a single occurrence for Task.Delay!
I'm confused between community opinions from the internet and official Microsoft book.
If Task.Delay is a good practice, why doesn't this book address it in any way?
Or did I miss something?