Implementation of a singleton HttpClient with generic methods I need advice for this implementation that I made for a service access portable class library referenced to Xamarin.Android and Xamarin.Ios projects. For now, it works fine, but I have doubts about its performance or if it would crash on simultaneous calls.

public class HttpClientBase : HttpClient
{

    private static readonly HttpClientBase instance = new HttpClientBase();

    static HttpClientBase() { }

    private HttpClientBase() : base() 
    {
        Timeout = TimeSpan.FromMilliseconds(15000);
        MaxResponseContentBufferSize = 256000;
    }

    public static HttpClientBase Instance
    {
        get
        {
            return instance;
        }
    }

    public async Task&lt;List&lt;T&gt;&gt; GetListItems&lt;T&gt;(string Url)
    {
        var uri = new Uri(string.Format(Constantes.BaseUrlApi, Url));
        var response = await GetAsync(uri);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            var Items = JsonConvert.DeserializeObject&lt;List&lt;T&gt;&gt;(content);
            return Items;
        }
        throw new Exception(response.ReasonPhrase);
    }

    public async Task&lt;T&gt; GetItem&lt;T&gt;(string Url)
    {
        var uri = new Uri(string.Format(Constantes.BaseUrlApi, Url));
        var response = await GetAsync(uri);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            var Item = JsonConvert.DeserializeObject&lt;T&gt;(content);
            return Item;
        }
        throw new Exception(response.ReasonPhrase);
    }

    public async Task PostItem&lt;T&gt;(T item, string url)
    {
        var uri = new Uri(string.Format(Constantes.BaseUrlApi, ""));
        var json = JsonConvert.SerializeObject(item);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        HttpResponseMessage response = null;
        response = await PostAsync(uri, content);
        if (response.IsSuccessStatusCode)
        {
            return;
        }
        throw new Exception(response.ReasonPhrase);
    }
}
General remarks

The naming and the design are ok. The only thing that could be improved is the


 HttpClientBase



It's not a base class so you shouldn't call it like this. I suggest HttpClientService.




Timeout = TimeSpan.FromMilliseconds(15000);



Or simply TimeSpan.FromSeconds(15);



Singleton

There are of course mutliple patters for creating a singleton but the one you chose is probably the right one Singleton by Jon Skeet clarification



Concurrency


  I have doubts about its performance or if it would crash on simultaneous calls.


I don't see actually anything that could be further optimized. You call only core APIs that should already do their best.

The methods don't share any data with each other so there is no risk in calling them in parallel.