Hello!
A few months ago I wrote about the UWP Community Toolkit, as an excellent set of assets that can help us if we are developing UWP Apps. A couple of days ago, a new version was released and it has quite a few new features. You can read the full post in the Windows Developer Blog.I really like this one:
A new helper to perform HTTP Requests, HttpHelper. It greatly simplifies us the code when we make requests of this type. For example
using (var request = new HttpHelperRequest(new Uri(twitterUrl), HttpMethod.Post)) { using (var response = await HttpHelper.Instance.SendRequestAsync(request)) { return await response.GetTextResultAsync(); } }
The most interesting thing about this helper is that internally implements a pooling of connections for our calls HTTP. Some time ago I read an article where, in a nutshell, cut you your fingers if you were using an HttpClient as if it were a DataBase connection.
The problem is that it is very tempting to use HttpClient follows, although by the nature of HttpClient, each instance that is within the using() will open a new connection, and in a system that requires many connections, we can find errors quickly. The friend, Simon Timms, explains it very well here (link).
using(var client = new HttpClient()) { //do something with http client }
Since well, the HTTP helper of UWP Community Toolkit 1.2, brings implemented factory pool of connections, with something as simple as a Singleton for the connection Http only with this, already worth try this toolkit.
Happy coding 😀
Saludos @ Toronto
El Bruno
References
- Windows Developer, Announcing UWP Community Toolkit 1.2
- GitHub, UWP Community Toolkit 1.2 Release Notes
- El Bruno, UWP Community Toolkit nice help and assets if you are developing Windows 10 Apps
- Asp.Net Monsters, YOU’RE USING HTTPCLIENT WRONG AND IT IS DESTABILIZING YOUR SOFTWARE
4 comments