Example #1
0
        public void Run()
        {
            if (IsDisposed)
            {
                return;
            }

            LastStatus = JobStatus.Running;
            try
            {
                Job.Run();
                LastStatus = JobStatus.Done;
            }
            catch (OperationCanceledException e)
            {
                if (!IsDisposed && e.CancellationToken == Cts.Token)
                {
                    LastStatus = JobStatus.Canceled;
                    JobChange?.Invoke(this, JobChangeEvent.Canceled);
                }
            }
            catch (FileOperationException e)
            {
                LastStatus = JobStatus.Error;

                Exception = e;
                JobChange?.Invoke(this, JobChangeEvent.ExceptionThrown);
            }
        }
Example #2
0
        private void OnJobProgressChange(float progress)
        {
            Progress = progress;

            if (Progress - lastProgressReported > 0.1)
            {
                JobChange?.Invoke(this, JobChangeEvent.OnProgressChange);
                lastProgressReported = Progress;
            }
        }
Example #3
0
 private static void OnJobChange(IJobView changedJob, JobChangeEvent changeEvent)
 {
     JobChange?.Invoke(changedJob, changeEvent);
 }