private async Task <bool> RunSequentiallyAsync(IDataStore fileInfo, Func <IDataStore, Task <bool> > preparation)
        {
            bool ok = false;
            await _progress.EnterSingleThread();

            try
            {
                if (_progress.Cancel)
                {
                    _eventArgs.Status = new FileOperationContext(fileInfo.FullName, ErrorStatus.Canceled);
                    return(ok);
                }
                ok = await preparation(fileInfo);

                if (_eventArgs.Status.ErrorStatus == ErrorStatus.Canceled)
                {
                    _progress.Cancel = true;
                }
            }
            finally
            {
                _progress.LeaveSingleThread();
            }
            return(ok);
        }
 public Task EnterSingleThread()
 {
     if (_isSingleThread)
     {
         return(Task.FromResult(default(object)));
     }
     _progress.EnterSingleThread();
     _isSingleThread = true;
     return(Task.FromResult(default(object)));
 }
 public Task EnterSingleThread()
 {
     return(_progress.EnterSingleThread());
 }