Skip to content

Clarify between "only a single instance should be created for an entire application" and "derived classes" #1326

Closed
@DeadX07

Description

@DeadX07

The guidance here is confusing because it implies that by deriving classes you would might have multiple instances, but the other guidance states this should not be the case. Which is it? Let's say you do derive from HttpClient to have a FacebookHttpClient and GoogleHttpClient, but they share the same static instance, how would this work throughout a application, especially if you need to execute concurrent http requests? What if you need to switch between using default credentials or not? I do understand about using all the sockets, connection pooling, and HttpClient acting as a session, but the guidance should be more clear if multiple are in fact allowed in a derived scenario, and guidance on how to best implement that. It would seem to me that there are scenarios where more than one HttpClient instance is going to be required by an application?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

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