Skip to content

Conversation

fnoring
Copy link

@fnoring fnoring commented Apr 26, 2018

Allow for disposing of the internally created HttpClient

Allow for disposing of the internally created HttpClient
Copy link

@tuwrraphael tuwrraphael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, but its required to set the _httpClient to null at least. I linked the Disposable implementation suggestion from Microsoft in the comment.

_httpClientHandler = httpClientHandler;
}

public void Dispose()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dispose should be implemented like that (as described in https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1063-implement-idisposable-correctly?view=vs-2017)

public class WebPushClient : IDisposable { public void Dispose() { Dispose(true); } public override void Dispose(bool disposing) { if (disposing) { if (_httpClient != null) { _httpClient.Dispose(); _httpClient = null; } } } }
@tuwrraphael
Copy link

Personally, I prefer generating the HttpRequestMessage using this class and feeding it to a HttClient form outside. On this way IHttpClientFactory etc can be used.

@coryjthompson
Copy link
Member

Handled in 80f8d43. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants