Exemplo n.º 1
0
        private async Task CopyAsync()
        {
            IsBusyCopying = true;
            FindFilesCommand.RaiseCanExecuteChanged();
            _copyCancellationTokenSource = new CancellationTokenSource();
            IListWithErrorDictionary <CopiedFile> copiedFiles = null;
            var cancelled = false;

            try
            {
                copiedFiles = await CopySpecificAsync(_copyCancellationTokenSource.Token);

                var tempList = PreviouslyCopiedFileList.ToList();
                tempList.AddRange(copiedFiles);
                PreviouslyCopiedFileList = tempList;
                _serializationHelper.WriteCopiedFileList(Model.DestinationPath, tempList);
            }
            catch (TaskCanceledException)
            {
                cancelled = true;
            }
            finally
            {
                Model.Items.Clear();
                IsBusyCopying = false;
                FindFilesCommand.RaiseCanExecuteChanged();
            }

            if (!cancelled)
            {
                ShowFinishedMessage(copiedFiles != null && !copiedFiles.Errors.Any());
            }
        }