//protected async Task<byte[]> TakePictureInternal(Size liveViewImageStreamSize, CameraSettingsDto settings, CancellationToken token)
        //{
        //    return await Task.Run(() => Run(liveViewImageStreamSize, settings, token), token);
        //}

        private async Task <byte[]> Run(Size liveViewImageStreamSize, CameraSettingsDto settings, CancellationToken token)
        {
            var pictures = new List <byte[]>();

            for (var i = 0; i < _pattern.Images.Count; i++)
            {
                _logger.Trace($"Фото №{i}");

                token.ThrowIfCancellationRequested();
                RaiseImageNumberChanged(i + 1);

                await Task.Delay(TimeSpan.FromSeconds(1), token);

                CommandManager.InvalidateRequerySuggested();

                for (var j = 5; j >= 0; j--)
                {
                    var j1 = j;
                    RaiseTimerElapsed(j1);
                    await Task.Delay(TimeSpan.FromSeconds(1), token);
                }
                _logger.Trace("Отсчёт закончен. Начало применения настроек для камеры.");


                SetCameraSettings(settings.SelectedPhotoAeMode, settings.SelectedPhotoWhiteBalance,
                                  settings.SelectedPhotoAvValue, settings.SelectedPhotoIsoSensitivity,
                                  settings.SelectedPhotoShutterSpeed);
                _logger.Trace("Настройки для камеры применены.");

                //await Task.Delay(TimeSpan.FromSeconds(1));

                //RaiseImageNumberChanged(i + 1);
                //await Task.Delay(TimeSpan.FromSeconds(1), token);
                token.ThrowIfCancellationRequested();
                byte[] picture = await _imageProcessor.DoTakePictureAsync();

                pictures.Add(picture);

                token.ThrowIfCancellationRequested();
                //await Task.Delay(TimeSpan.FromSeconds(3), token); //todo
                _logger.Trace("Фотография сделана. Начало применения настроек для LiveView");

                SetCameraSettings(settings.SelectedAeMode, settings.SelectedWhiteBalance,
                                  settings.SelectedAvValue, settings.SelectedIsoSensitivity,
                                  settings.SelectedShutterSpeed);
                _logger.Trace("Настройки для камеры применены.");

                _logger.Trace("Стоп LiveView.");
                StopLiveView();
                _logger.Trace("Старт LiveView.");
                StartLiveView();
            }

            byte[] result = _imageUtils.ProcessImages(pictures, liveViewImageStreamSize, _pattern);
            return(result);
        }