Skip to content

There is no clear indication whether resolving services from DI is thread safe #47086

Closed

Description

@petrroll

Type of issue

Missing information

Description

While there're tips for how to deal with thread safety in our code (singletons) and information about the guaranteed of them being created, there's no general info about whether DI resolving is or isn't thread safe. And I couldn't find it anywhere else either.

It seems it's kinda naturally implied that it must be (and duh, it must be) but it should be very explicitly said somewhere.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/dependency-injection-guidelines.md

Document Version Independent Id

7fb2be80-cb54-27bf-4f93-423d8540429e

Platform Id

df1bff59-742c-a7b3-cfc6-4fc1f6510458

Article author

@IEvangelist

Metadata

  • ID: 8d1c8ef1-6a01-df24-34ad-570f88df9303
  • PlatformId: df1bff59-742c-a7b3-cfc6-4fc1f6510458
  • Service: dotnet-fundamentals

Related Issues

Activity

  1. petrroll commented on Jul 3, 2025

    @petrroll
    Author

    It should also be noted as thread safety remarks on the interfaces.

    https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider.getservice?view=net-9.0

  2. BillWagner commented on Nov 6, 2026

    @BillWagner
    Member

    The DI thread-safety section now says that concurrent resolution from a built IServiceProvider or IServiceScope is safe for the built-in .NET container. Its note explicitly says that the guarantee doesn't make resolved objects thread-safe. dotnet/docs#50123 merged the clarification; the current text was checked directly.

    Closing this documentation issue on that basis.

  3. added a commit that references this issue on Nov 30, 2026
    d370f47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions