private void MainViewOnClosing(object sender, CancelEventArgs e)
        {
            var waitScreen = new SplashScreenWindow("waiting for backgrond operations")
            {
                Owner = MainWindow
            };

            waitScreen.Show();
            _repository?.Close();
            waitScreen.Close();
        }
        private async void ApplicationStartup(object sender, StartupEventArgs e)
        {
            var splashScreen = new SplashScreenWindow("Initializing repository");

            splashScreen.Show();

            MainWindowViewModel mainViewModel;

            var mainView      = new MainWindow();
            var windowService = new WindowService(mainView);

            var repositoryPath = Settings.Default.RepositoryPath;
            var cachePath      = Settings.Default.CachePath;

            var cache = new DbRepository(cachePath);

            if (Settings.Default.UseFavoriteCache)
            {
                if (DbRepository.CheckRepositoryConnection(repositoryPath))
                {
                    _repository   = new DbRepository(repositoryPath, cache);
                    mainViewModel = new MainWindowViewModel(_repository, windowService, false);
                }
                else
                {
                    _repository   = cache;
                    mainViewModel = new MainWindowViewModel(cache, windowService, true);
                }
            }
            else
            {
                _repository   = new DbRepository(repositoryPath);
                mainViewModel = new MainWindowViewModel(_repository, windowService, false);
            }

            await _repository.Initialize();

            mainView.DataContext = mainViewModel;
            mainView.Closing    += MainViewOnClosing;

            splashScreen.Close();
            MainWindow = mainView;
            mainView.Show();
        }