Based on This Post - I changed my code because of a slow response when doing a simple Get - it takes about 54-50 seconds. Posting to exactly the same URL using nodejs takes about 10 seconds.
public class TrayWeighScan
{
private static readonly HttpClient httpClient = new HttpClient();
public async Task<string> doOrder(string orderNumber, decimal weight )
{
var url = "http://r2hserver/logistics/weighscan?orderNumber="+orderNumber+"&weight="+weight.ToString("F2");
using (HttpResponseMessage response = await httpClient.GetAsync(url).ConfigureAwait(false))
{
response.EnsureSuccessStatusCode(); // throws if 404, 500, etc.
string responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return responseText;
}
}
}
and at the start of my winforms form I have
private TrayWeighScan trayWeighScan = new TrayWeighScan();
Then I call it with this code:
var jsonString = trayWeighScan.doOrder(barcode, Decimal.Parse(weight)).Result;