public static async Task Main() { var downloader = FileTransferService.GetDownloaderBuilder() .UseDefaultConfigure() .From("https://file.mrs4s.me/file/3898c738090be65fc336577605014534") .To($@"{Environment.CurrentDirectory}\download-multi-thread.test") .Build(); ReadyToRun(downloader); //await TimeSpan.FromSeconds(10); //WriteLine("Try to Stop... "); //downloader.Stop(); //downloader.Dispose(); //var data = downloader.ToJsonString(); //var jObject = downloader.ToJObject(); //var json = jObject.ToString(); //var downloaderFromJson = FileTransferService // .GetDownloaderBuilder() // .UseDefaultConfigure() // .Build(data); //ReadyToRun(downloaderFromJson); ReadKey(); }
public static async Task Main() { var downloader = FileTransferService.GetDownloaderBuilder() .UseDefaultConfigure() .From("https://file.mrs4s.me/file/3898c738090be65fc336577605014534") //.From("https://accelerider-my.sharepoint.com/personal/cs02_onedrive_accelerider_com/_layouts/15/download.aspx?UniqueId=b8a04e28-cbe7-46b6-a7e9-ff1dc364539e&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvYWNjZWxlcmlkZXItbXkuc2hhcmVwb2ludC5jb21AMjZmYTQ2ZDYtNDA3YS00YjMwLWJmMjYtOTEwZmFhMjZiZGQ2IiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwIiwibmJmIjoiMTUzOTg4NDEyMSIsImV4cCI6IjE1Mzk4ODc3MjEiLCJlbmRwb2ludHVybCI6ImZPVjloMFdhOFlLT3hNVVhOM0w4RDhySXBnVWVvYkt0ZTI1TVg2UUgrWkU9IiwiZW5kcG9pbnR1cmxMZW5ndGgiOiIxNjQiLCJpc2xvb3BiYWNrIjoiVHJ1ZSIsImNpZCI6IlpEVmhOemxqT0RZdFpXSmxNUzAwWm1GaExUbGxNRGd0TTJVeE9EZGtaREExTVRNMiIsInZlciI6Imhhc2hlZHByb29mdG9rZW4iLCJzaXRlaWQiOiJaVGxpWXpsaVltSXROVFkyTWkwMFlqazNMVGd6TVdNdFl6ZzFNMkk1TkRobU0yTmkiLCJhcHBfZGlzcGxheW5hbWUiOiJBY2NlbGVyaWRlciIsInNpZ25pbl9zdGF0ZSI6IltcImttc2lcIl0iLCJhcHBpZCI6ImIyZjY2NTg0LTBhZGMtNDEzNS1hOTMwLTdiZjQ2YmM3YzdkNCIsInRpZCI6IjI2ZmE0NmQ2LTQwN2EtNGIzMC1iZjI2LTkxMGZhYTI2YmRkNiIsInVwbiI6ImNzMDJAb25lZHJpdmUuYWNjZWxlcmlkZXIuY29tIiwicHVpZCI6IjEwMDMwMDAwQTQyRUM5QjEiLCJzY3AiOiJhbGxmaWxlcy53cml0ZSBhbGxwcm9maWxlcy5yZWFkIiwidHQiOiIyIiwidXNlUGVyc2lzdGVudENvb2tpZSI6bnVsbH0.SDl1TTZwMzFPalRwRHBJMVRMUEJnNkhxZDg0a3kzcENSTG90TDUxbFZpST0&ApiVersion=2.0") .To(@"C:\Users\Dingp\Desktop\DownloadTest\download-multi-thread.rmvb") .Build(); ReadyToRun(downloader); await TimeSpan.FromSeconds(30); WriteLine("Try to Stop... "); downloader.Stop(); downloader.Dispose(); var json = downloader.ToJson(); var downloaderFromJson = FileTransferService.GetDownloaderBuilder().UseDefaultConfigure().Build(json); ReadyToRun(downloaderFromJson); ReadKey(); }
public static async Task Main() { var downloader = FileTransferService.GetFileDownloaderBuilder() .UseDefaultConfigure() .Build(); var disposable1 = downloader.SubscribeReport(); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed downloader .From("https://file.mrs4s.me/file/3898c738090be65fc336577605014534") .To(@"C:\Users\Dingp\Desktop\DownloadTest\download-multi-thread.rmvb"); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed WriteLine("Enter ant key to Start downloader: "); ReadKey(true); var cancellationTokenSource = new CancellationTokenSource(); WriteLine("Try to ActivateAsync... "); await downloader.ActivateAsync(cancellationTokenSource.Token); await TimeSpan.FromSeconds(10); WriteLine("Try to Suspend... "); downloader.Suspend(); var json = downloader.ToJson(); WriteLine("Try to Dispose... "); downloader.Dispose(); await TimeSpan.FromSeconds(5); var downloader2 = FileTransferService.GetFileDownloaderBuilder() .UseDefaultConfigure() .Build(); downloader2.SubscribeReport(); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed downloader2.FromJson(json); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed WriteLine("Try to ActivateAsync... "); await downloader2.ActivateAsync(cancellationTokenSource.Token); //FileTransferService // .GetFileDownloaderBuilder() // .UseDefaultConfigure() // .Build() // .FromJson(json); //await TimeSpan.FromMilliseconds(5000); //WriteLine("downloader has been disposed. "); //downloader.Dispose(); ReadKey(); }