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<List<T>> GetListItems<T>(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<List<T>>(content);            return Items;        }        throw new Exception(response.ReasonPhrase);    }    public async Task<T> GetItem<T>(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<T>(content);            return Item;        }        throw new Exception(response.ReasonPhrase);    }    public async Task PostItem<T>(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);    }}
Implementation of a singleton HttpClient with generic methods
c#;web services;asp.net web api;xamarin
General remarksThe naming and the design are ok. The only thing that could be improved is the HttpClientBaseIt'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);SingletonThere are of course mutliple patters for creating a singleton but the one you chose is probably the right one Singleton by Jon Skeet clarificationConcurrencyI 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.