DownloadBranch() public method

public DownloadBranch ( DownloadBranchProperties properties, CancellationToken token = newCancellationToken() ) : Task
properties DownloadBranchProperties
token System.Threading.CancellationToken
return Task
        public async Task TestProPlusGenerator()
        {

            var proPlusDownloader = new ProPlusDownloader();
            proPlusDownloader.DownloadFileProgress += (sender, progress) =>
            {
                var percent = progress.PercentageComplete;
                if (percent != null)
                {
                    
                }
            };

            await proPlusDownloader.DownloadBranch(new DownloadBranchProperties()
            {
                BranchName = "Current",
                OfficeEdition = OfficeEdition.Office64Bit,
                TargetDirectory = @"e:\Office",
                Languages = new List<string>() { "en-us", "fr-fr"}
            });

            
        }
        private async Task DownloadOfficeFiles()
        {
            try
            {
                SetTabStatus(false);
                GlobalObjects.ViewModel.BlockNavigation = true;
                _tokenSource = new CancellationTokenSource();

                UpdateXml();

                ProductUpdateSource.IsReadOnly = true;
                UpdatePath.IsEnabled = false;

                DownloadProgressBar.Maximum = 100;
                DownloadPercent.Content = "";

                var configXml = GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml;
                var startPath = ProductUpdateSource.Text.Trim();

                if (!string.IsNullOrEmpty(startPath))
                {
                    GlobalObjects.ViewModel.DownloadFolderPath = startPath;
                }

                var channelItems = (List<Channel>) lvUsers.ItemsSource;

                var taskList = new List<Task>();
                _lastUpdated = DateTime.Now.AddDays(-10);
                var startTime = DateTime.Now;

                foreach (var channelItem in channelItems)
                {
                    if (!channelItem.Selected) continue;
                    var branch = channelItem.ChannelName;

                    var task = Task.Run(async () =>
                    {
                        try
                        {
                            var proPlusDownloader = new ProPlusDownloader();
                            proPlusDownloader.DownloadFileProgress += (senderfp, progress) =>
                            {
                                if (!_tokenSource.Token.IsCancellationRequested)
                                {
                                    DownloadFileProgress(progress, channelItems, channelItem);
                                }
                            };

                            proPlusDownloader.VersionDetected += (sender, version) =>
                            {
                                UpdateVersion(channelItems, channelItem, version.Version);
                            };

                            if (string.IsNullOrEmpty(startPath)) return;

                            var languages =
                                (from product in configXml.Add.Products
                                    from language in product.Languages
                                    select language.ID.ToLower()).Distinct().ToList();

                            var officeEdition = GetSelectedEdition();

                            var buildPath = GlobalObjects.SetBranchFolderPath(branch, startPath);

                            Directory.CreateDirectory(buildPath);

                            var setVersion = channelItem.DisplayVersion;

                            await proPlusDownloader.DownloadBranch(new DownloadBranchProperties()
                            {
                                BranchName = branch,
                                OfficeEdition = officeEdition,
                                TargetDirectory = buildPath,
                                Languages = languages,
                                Version = setVersion
                            }, _tokenSource.Token);

                            if (!_tokenSource.Token.IsCancellationRequested)
                            {
                                UpdatePercentage(channelItems, channelItem.Name);
                            }

                            LogAnaylytics("/ProductView", "Download." + branch);
                        }
                        catch (Exception ex)
                        {
                            if (!ex.Message.ToLower().Contains("aborted"))
                            {
                                ex.LogException(false);
                                UpdateError(channelItems, channelItem.Name, "ERROR: " + ex.Message);
                            }
                        }
                    });

                    if (!GlobalObjects.ViewModel.AllowMultipleDownloads)
                    {
                        await task;
                    }

                    if (_tokenSource.Token.IsCancellationRequested) break;

                    var timeTaken = DateTime.Now - startTime;

                    taskList.Add(task);
                    await Task.Delay(new TimeSpan(0, 0, 5));
                }

                await Task.Delay(new TimeSpan(0, 0, 1));

                foreach (var task in taskList)
                {
                    if (task.Exception != null)
                    {

                    }
                    await task;
                }

                //MessageBox.Show("Download Complete");
            }
            finally
            {
                SetTabStatus(true);
                GlobalObjects.ViewModel.BlockNavigation = false;
                ProductUpdateSource.IsReadOnly = false;
                UpdatePath.IsEnabled = true;
                DownloadProgressBar.Value = 0;
                DownloadPercent.Content = "";

                DownloadButton.Content = "Download";
                _tokenSource = new CancellationTokenSource();
            }
        }