/// <summary> /// Start backing up all the <see cref="FolderPathsToBackup"/> to <see cref="BackupFolder"/> /// </summary> async void StartBackupAsync(IProgress <int> progress) { IsBackupRunning = true; await Task.Run(() => { int count = 0; Parallel.ForEach <DisplayItemControlViewModel>(DisplayItems, async(item) => { await item.StartBackup(); if (item.BackupStatus.IsBackupDone) { count++; progress.Report(count); if (count == DisplayItems.Count) { IsBackupRunning = false; IsBackupDone = true; ViewModelLocator.CacheViewModel.Details.LastBackupTime = DateTime.Now; ReportFile.WriteToLog("Backup has ended successfully!"); ReportFile.SaveToLog(); // Redircet to details page GoToDetails(); } } }); }); }
public void RunBackup() { if (!IsBackupRunning) { ReportFile.ClearLog(); ReportFile.WriteToLog($"Starting backup..."); // In the begining the backup is not yet started IsBackupDone = false; // Setting all the infomation to Items SetItemsInformation(); // Start the backup StartBackupAsync(CompletedItemsProgress); } }