I have an application that has to download a large payload (a few hundred MB), and in some circumstances on a device with a slow connection.
So I have this:
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(activeResource.Content);
client.Timeout = TimeSpan.FromHours(6);
binary = await client.GetByteArrayAsync(activeResource.Content);
}
I’ve set the Timeout to be 6 hours to be safe – in realistic terms we have seem instances where it has taken up to an hour to download.
My question is: Does this Timeout specify the timeout for the entire transaction, or is it the timeout while waiting for a response?
In other words, what I want is, to allow for up to 6 hours (or thereabouts) for the entire download to complete, but if, say there is no data coming through, due to, say a dropped connection, I don’t want the user to have to wait 6 hours to find out.
And if it’s the former, how do I set a short timeout for waiting for a response from the server, but allow a long time for the download to complete?