string dowloadFilePath = @"D:\InstanceType.json"; Task<bool> task = DownloadPriceListCsvFromAWS("https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/us-gov-east-1/index.json", dowloadFilePath); task.Wait(60000); if (task.IsCompleted) { Console.WriteLine("File download compalete {0}", task.Result); } else { Console.WriteLine("Download does not seem to be completed within the specified time"); WebClient webClient = (WebClient)task.AsyncState; webClient.CancelAsync(); bool bRet = task.Result; if (File.Exists(dowloadFilePath)) { Console.WriteLine("Partially downloaded file exist. Cleaning it up"); File.Delete(dowloadFilePath); } }