Skip to content

Analyzer proposal: Use Task.Delay instead of Thread.Sleep in an async method #754

Description

@nbarbettini

Using Thread.Sleep() inside an async method is a bad idea. await Task.Delay() is a drop-in replacement. It would be great to have an analyzer rule (and an accompanying code fix) to catch accidental use of Thread.Sleep.

Back on the old AsyncUsageAnalyzers repo, there was this discussion: DotNetAnalyzers/AsyncUsageAnalyzers#2
And also a related PR: DotNetAnalyzers/AsyncUsageAnalyzers#50

Is vs-threading the right place for an analyzer like this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions