void UploadManager_UploadFinished(object sender, UploadResult e)
 {
     this.Dispatcher.InvokeAsync(() =>
     {
         if (e.Success)
         {
             _captureController.Logger.info("Upload Finished: " + _captureController.Session.CompressedScanFile);
             _endAndStartNewSession();
         }
     });
 }
Пример #2
0
        public async Task<UploadResult> PerformUpload()
        {
            if (this.InProgress)
                throw new InvalidOperationException("Uploader was already started");

            _started = true;
            _result = null;
            this.Waiting = false;
            OnPropertyChanged("InProgress");

            _cancellationTokenSource = new CancellationTokenSource();
             
            UploadResult result;
            try
            {
                result = await Upload(_session, _cancellationTokenSource.Token);
            }
            catch (OperationCanceledException)
            {
                _canceled = true;
                result =  new UploadResult { Success = false,  Canceled = true };
               
            }

            if (Completing != null) Completing(this, result);

            _result = result;

            if (Completed != null) Completed(this, result);
            
            OnPropertyChanged("InProgress");
            OnPropertyChanged("Success");
            OnPropertyChanged("Result");

            return result;
        }