Skip to content

Thread.Sleep instead of Task.Delay? #84

@Almantask

Description

@Almantask

I am surprised to see

Thread.Sleep(Timeout.Infinite);

and not

async Task Main...
...
await Task.Delay(Timeout.Infinite);

My concern is that, Thread.Sleep is a blocking operation. Won't it completely disable 1 thread from doing any work at all times? Won't Task.Delay give the thread back to the scheduler instead so it could do whatever it has to, while it simply await and not blocks?

Please let me know if the example is simply outdated or if it is justified. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions