#Windows10 – UWP Community Toolkit 1.2. With connection pooling support for HttpRequests !


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




Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: