/// <summary>
        /// Called when rendering thread has stopped. Meaning that game has ended.
        /// </summary>
        private void RendererStopped(object sender, RunWorkerCompletedEventArgs e)
        {
            _logicWorker.DoWork -= _logic.Run;
            _renderWorker.DoWork -= _renderer.Run;
            _renderer = null;
            _logic = null;

            var done = false;
            if (_win)
            {
                MessageBox.Show("Hey, cheater, you won!", "Holy cow!");
                done = true;
            }
            else
            {
                var replay = MessageBox.Show("Hey, loooser. Retry?", "Looooooooseeeeer", MessageBoxButton.YesNo);
                done = replay == MessageBoxResult.No;
            }

            if (done)
            {
                var mainWindow = new MainWindow();
                App.Current.MainWindow = mainWindow;
                this.Close();
                mainWindow.Show();
            }
            else
            {
                Init();
            }
        }
        /// <summary>
        /// Starts new game. Runs game logic and rendering threads.
        /// </summary>
        private void Init()
        {
            _renderer = new Renderer(this);
            _logic = new GameLogic(this, _renderer);

            if (contentGrid.ActualWidth > 0)
                ReinitFieldBitmap((int)contentGrid.ActualWidth, (int)contentGrid.ActualHeight);

            _logicWorker.DoWork += _logic.Run;
            _logicWorker.RunWorkerAsync();

            _renderWorker.DoWork += _renderer.Run;
            _renderWorker.RunWorkerCompleted += RendererStopped;
            _renderWorker.WorkerSupportsCancellation = true;
            _renderWorker.RunWorkerAsync();

            _renderFrameTimer.Start();
        }