Exemple #1
0
        /// <summary>
        /// Создания новой задачи разматывания очереди.
        /// </summary>
        public void StartQueue()
        {
            DispouseSoundMessageChangeRx = SoundMessageChangeRx.Subscribe(DefinitionStartStopQueueRxEventHandler);

            _cts         = new CancellationTokenSource();
            _currentTask = Task.Run(async() =>                //ЗАПУСК ЗАДАЧИ
            {
                //await CycleInvoke();
                await CycleInvokeUsingInternalSoundPlayerQueue();
            }, _cts.Token);

            IsWorking = true;

            _currentTask.ContinueWith(t =>                   //ОБРАБОТКА ОТМЕНЫ ЗАДАЧИ
            {
                IsWorking = false;
                DispouseSoundMessageChangeRx.Dispose();
            },
                                      TaskContinuationOptions.OnlyOnCanceled);

            _currentTask.ContinueWith(t =>                  //ОБРАБОТКА ЗАВЕРШЕННОЙ ЗАДАЧИ
            {
                IsWorking = false;
                DispouseSoundMessageChangeRx.Dispose();
            },
                                      TaskContinuationOptions.OnlyOnRanToCompletion);

            _currentTask.ContinueWith(t =>                  //ОБРАБОТКА Exception В ЗАДАЧИ
            {
                var ex = t.Exception;
                //...    обработка ошибки
                IsWorking = false;
                DispouseSoundMessageChangeRx.Dispose();
            },
                                      TaskContinuationOptions.OnlyOnFaulted);
        }
Exemple #2
0
 public void Dispose()
 {
     StopQueue();
     _player?.Dispose();
     DispouseSoundMessageChangeRx.Dispose();
 }