コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: liux0229/scratch
        private void startColumnClick(object sender, RoutedEventArgs e)
        {
            if (input == null) return;

            if (nextColumn == -1 || boardChanged)
            {
                board.ClearPath();
                nextColumn = input.GetLength(1) - 1;
                boardChanged = false;
                solver = new OnePersonGameSolver();
                solver.BeginSolve(input);
            };

            var task = new Task(() =>
            {
                DisplayResult("Start solving next column...");
                solver.BeginSolveNextColumn(sol =>
                {
                    ProcessSolution(sol, null);
                });
            });

            --nextColumn;
            task.Start();
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: liux0229/scratch
        private void startClick(object sender, RoutedEventArgs e)
        {
            if (input == null) return;

            Stopwatch timer = new Stopwatch();
            var task = new Task<Solution>(() =>
            {
                DisplayResult("Start solving...");
                timer.Start();
                nextColumn = -1;
                boardChanged = false;
                solver = new OnePersonGameSolver();
                return solver.Solve(input);
            });
            task.ContinueWith(result =>
            {
                ProcessSolution(result.Result, timer.Elapsed);
            });
            task.Start();
        }