RestClient freeze when device is turned off in middle of downloading file

Viewed 49

I'am working with WPF application which communicates with camera using REST API. There are background worker which tries to download some specific images. However if download starts and camera is turned off in middle of downloading then freeze occurs. Nor read ReadWriteTimeout nor TimeOut seems to help. No exceptions are thrown. Any ideas how can I make timeout work in this situation?


private byte[] DownloadPhoto(string url)
{
     var client = new RestClient(url);
     var request = new RestRequest("#", Method.GET);
     request.ReadWriteTimeout = 30000;
     request.Timeout = 30000;
     var fileBytes = client.ExecuteAsync(request).Result.RawBytes;
     return fileBytes;
}
0 Answers
Related