Skip to main content

Posts

Showing posts from February, 2019

Downloading a file : TaskCompleteSource approach

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;               ...