public static async Task Main(string[] args) { var cancellationTokenSource = new CancellationTokenSource(); var webClientAsync = new WebClientAsync(); cancellationTokenSource.CancelAfter(5000); var content = await webClientAsync.DownloadAsync(new Uri("https://ftp.byfly.by/test/500Mb"), cancellationTokenSource.Token); Console.WriteLine(content.Length); }
public void GetVersionsFromWeb(Action <VersionsResponse> onDone) { IWebClient webClient = new WebClientAsync(); webClient.Get(Config.VersionsURL, (message) => { try { WebClient.ProcessResponse(message, (data) => { var result = JsonUtility.FromJson <VersionsResponse>(data); onDone?.Invoke(result); }, (code) => { MessageHelper.Alert("Error: " + code); }); } catch (Exception ex) { MessageHelper.ThrowException(ex); } }, MessageHelper.ThrowException); }