コード例 #1
0
 private void OnFinished(object sender, BackgroundWorkerType e)
 {
     System.Diagnostics.Debug.WriteLine("TimedBackgroundWorker.OnFinished()");
     Deferral?.Complete();
     BackgroundEngine.Finished -= OnFinished;
     BackgroundEngine.Dispose();
 }
コード例 #2
0
        public ProcessingStatusForm(int totalValue, BackgroundWorkerType workerType, ELearningService service = null)
        {
            InitializeComponent();
            Dispatcher.Invoke(() => { progressBar.Value = 0; });
            label.Content   = string.Format(ELearningLabText.ProgressStatusLabelFormat, 0);
            this.totalValue = totalValue;
            this.workerType = workerType;
            this.service    = service;
            worker          = new BackgroundWorker();
            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = true;
            switch (workerType)
            {
            case BackgroundWorkerType.AudioGenerationService:
                worker.DoWork += Worker_DoWorkForAudioGenerationService;
                break;

            case BackgroundWorkerType.ELearningLabService:
                worker.DoWork += Worker_DoWorkForELearningLabService;
                break;

            default:
                break;
            }
            worker.ProgressChanged    += Worker_ProgressChanged;
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
            worker.RunWorkerAsync();
        }
コード例 #3
0
 private void OnFinished(object sender, BackgroundWorkerType e)
 {
     System.Diagnostics.Debug.WriteLine("TimedBackgroundWorker.OnFinished()");
     Deferral?.Complete();
     BackgroundEngine.Finished -= OnFinished;
     BackgroundEngine.Dispose();
 }
コード例 #4
0
        public void GetWorker_SupplyDesiredWorkerType_ReturnsRespectiveWorkerInstance(BackgroundWorkerType enumType, Type expectedType)
        {
            // arrange
            IBackgroundWorkerFactory factory = InitializeFactory();

            // act
            IBackgroundWorker result = factory.GetWorker(enumType);

            // assert
            Assert.IsInstanceOf(expectedType, result);
        }
 private void OnFinished(object sender, BackgroundWorkerType type)
 {
     if (type == BackgroundWorkerType.AdvertisementWorker)
     {
         BackgroundEngine.ProcessDelayedActionsAsync(false).ConfigureAwait(false);
     }
     else
     {
         Deferral?.Complete();
         BackgroundEngine.Finished -= OnFinished;
         BackgroundEngine?.Dispose();
     }
 }
コード例 #6
0
        public IBackgroundWorker GetWorker(BackgroundWorkerType workerType)
        {
            IBackgroundWorker result = null;

            if (workerType == BackgroundWorkerType.Sync)
            {
                result = new BackgroundWorkerSync();
            }
            else if (workerType == BackgroundWorkerType.Async)
            {
                result = new BackgroundWorkerAsync();
            }

            return(result);
        }
コード例 #7
0
        public IBackgroundWorker GetWorker(BackgroundWorkerType workerType)
        {
            IBackgroundWorker result = null;

            if (workerType == BackgroundWorkerType.Sync)
            {
                result = new BackgroundWorkerSync();
            }
            else if (workerType == BackgroundWorkerType.Async)
            {
                result = new BackgroundWorkerAsync();
            }

            return result;
        }
        public void GetWorker_SupplyDesiredWorkerType_ReturnsRespectiveWorkerInstance(BackgroundWorkerType enumType, Type expectedType)
        {
            // arrange
            IBackgroundWorkerFactory factory = InitializeFactory();

            // act
            IBackgroundWorker result = factory.GetWorker(enumType);

            // assert
            Assert.IsInstanceOf(expectedType, result);
        }
 private void OnFinished(object sender, BackgroundWorkerType type)
 {
     if (type == BackgroundWorkerType.AdvertisementWorker)
     {
         BackgroundEngine.ProcessDelayedActionsAsync(false).ConfigureAwait(false);
     }
     else
     {
         Deferral?.Complete();
         BackgroundEngine.Finished -= OnFinished;
         BackgroundEngine?.Dispose();
     }
 }