Ejemplo n.º 1
0
 // Apply the editor's action to a photo.
 public void Apply()
 {
     try {
         ProcessingStarted?.Invoke(Label, State.Items.Length);
         TryApply();
     } finally {
         ProcessingFinished?.Invoke();
     }
 }
Ejemplo n.º 2
0
        public void ProcessPcaps(IEnumerable <string> filesPaths, string liveCaptureDevice = null)
        {
            _processingPrecentsPredicator.AddFiles(new HashSet <FileInfo>(filesPaths.Select(fp => new FileInfo(fp))));

            foreach (var filePath in filesPaths)
            {
                this.ProcessPcap(filePath);
            }
            ProcessingFinished?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 3
0
        private async Task ProcessAddingQueue()
        {
            try
            {
                messenger.Send(
                    this,
                    new SwitchLoadingIndicatorMessage
                {
                    Switcher = true
                });

                while (attachmentsQueue.Count != 0)
                {
                    await attachmentService.AddAsync(SelectedAccount, attachmentsQueue.Peek()).ConfigureAwait(false);

                    attachmentsQueue.Dequeue();
                }

                messenger.Send(
                    this,
                    new SwitchLoadingIndicatorMessage
                {
                    Switcher = false
                });

                ProcessingFinished?.Invoke();
            }
            catch (AttachmentExistsException)
            {
                dialogId = Guid.NewGuid();

                messenger.Send(
                    this,
                    new SwitchLoadingIndicatorMessage
                {
                    Switcher = false
                });

                messenger.Send(
                    this,
                    new ConfirmDialogRequestMessage
                {
                    DialogMode         = DialogModes.OkCancel,
                    Title              = Titles.Replace,
                    Message            = string.Format(Templates.ReplaceMessage, Path.GetFileName(attachmentsQueue.Peek())),
                    DialogId           = dialogId,
                    OnResponseReceived = ReplaceResponseReceivedHandler
                });
            }
            catch (UnauthorizedAccessException)
            {
                NotifyUnauthorizedAccess();
            }
        }
Ejemplo n.º 4
0
 public void Run(Func <Stream> getSrcStream, Func <Stream> getDstStream, int blockLength)
 {
     if (IsRunning)
     {
         return;
     }
     IsRunning = true;
     new Thread(() =>
     {
         GetSourceStream      = getSrcStream;
         GetDestinationStream = getDstStream;
         _blockLength         = blockLength;
         Exception exception  = null;
         _readThread          = ThreadHelper.RunGuarded(ReadThreadFunction, (ex) =>
         {
             _isCanceled = true;
             exception   = ex;
         });
         _writeThread = ThreadHelper.RunGuarded(WriteThreadFunction, (ex) =>
         {
             _isCanceled = true;
             exception   = ex;
         });
         _processThreads = new Thread[Environment.ProcessorCount];
         for (int i = 0; i < _processThreads.Length; i++)
         {
             _processThreads[i] = ThreadHelper.RunGuarded(ProcessThreadFunction, (ex) =>
             {
                 _isCanceled = true;
                 exception   = ex;
             });
         }
         ThreadHelper.WaitThreads(_readThread);
         _readQueue.Close();
         ThreadHelper.WaitThreads(_processThreads);
         _writeQueue.Close();
         ThreadHelper.WaitThreads(_writeThread);
         CompressionResultType crType = CompressionResultType.Success;
         if (exception == null)
         {
             crType = _isCanceled ? CompressionResultType.Cancelled : CompressionResultType.Success;
         }
         else
         {
             crType = CompressionResultType.Fail;
         }
         IsRunning = false;
         ProcessingFinished?.Invoke(this, new CompressionResult(crType, exception));
     }).Start();
 }
Ejemplo n.º 5
0
 private void Run()
 {
     try
     {
         ProcessingStarted?.Invoke();
         for (int i = 0; i < 100; ++i)
         {
             _tokenSource.Token.ThrowIfCancellationRequested();
             Thread.Sleep(TimeSpan.FromSeconds(1.0));
             _progress.Report(i);
         }
     }
     catch { }
     finally
     {
         _progress.Report(100);
         lock (_guard)
         {
             _isRunning = false;
         }
         ProcessingFinished?.Invoke();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Generates the <see cref="ProcessingFinished"/> event with provided params.
 /// </summary>
 /// <param name="result">Resdult of processing.</param>
 /// <param name="args">Shared object.</param>
 protected void Finalize(bool result, object args)
 {
     // Inform subscribers.
     ProcessingFinished?.Invoke(this, result, args);
 }