I sent a request to server using HttpClient, how can I limit the boot time, for example, 30 seconds?
Here is my method:
private async Task<HttpResponseMessage> SendRequestAsync(HttpRequestMessage request)
{
try
{
using (var client = new HttpClient())
{
return await client.SendAsync(request);
}
}
catch (ArgumentNullException e)
{
Console.WriteLine(e.Message);
throw new HttpRequestException();
}
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
throw new HttpRequestException();
}
catch (HttpRequestException e)
{
Console.WriteLine(e.Message);
throw;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw new HttpRequestException();
}
}
How can i limit download time?