private async void Solve() { OnCreateBoard(new CreateBoardEventArgs(CurrentBoard)); if (!CurrentBoard.IsSolvable()) { if (!_dialogService.ShowConfirmation("Looks like this board is not solvable. Are you sure you want to continue?")) { return; } } CreateCancellationToken(); SearchResult = null; State = EWorkState.SEARCHING; try { SearchResult = await _puzzleSolverService.SolveAsync(CurrentBoard, SelectedAlgorithm, SelectedHeuristicFunction, _cancellationToken); if (!SearchResult.Success) { _dialogService.ShowError("Solution was not found."); } else { StartShowingMoves(); return; } } catch (OperationCanceledException) { } catch (Exception ex) { _dialogService.ShowError(ex.Message); } State = EWorkState.IDLE; }