private static void Test() { //Initialize the logger and its events var logger = new EventBasedLogger(); logger.Log += WriteLog; logger.Debug += WriteDebug; logger.Progress += WriteProgress; //create the downloader object and set its logger var downloader = new FileDownloader { Logger = logger }; //enqueu two images var items = new Queue<DownloadItem>(); items.Enqueue(new DownloadItem { Address = new Uri("https://www.google.com/images/srpr/logo3w.png"), Path = "google.png" }); items.Enqueue(new DownloadItem { Address = new Uri("http://www.bing.com/community/cfs-filesystemfile.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-41-77-metablogapi/6644.b_2D00_fund_2D00_logo_5F00_3669B89F.png"), Path = "bing.png" }); //create cancellation token source using (var source = new CancellationTokenSource()) { //Start download... // Note: You can use async, instead of the synced version downloader.StartDownload(items, source.Token); } }
private static void Test() { //Initialize the logger and its events var logger = new EventBasedLogger(); logger.Log += WriteLog; logger.Debug += WriteDebug; logger.Progress += WriteProgress; //create the downloader object and set its logger var downloader = new FileDownloader { Logger = logger }; //enqueu two images var items = new Queue <DownloadItem>(); items.Enqueue(new DownloadItem { Address = new Uri("https://www.google.com/images/srpr/logo3w.png"), Path = "google.png" }); items.Enqueue(new DownloadItem { Address = new Uri("http://www.bing.com/community/cfs-filesystemfile.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-41-77-metablogapi/6644.b_2D00_fund_2D00_logo_5F00_3669B89F.png"), Path = "bing.png" }); //create cancellation token source using (var source = new CancellationTokenSource()) { //Start download... // Note: You can use async, instead of the synced version downloader.StartDownload(items, source.Token); } }