private async Task DoParseRoute() { var ParsedPanel = PanelParser.GetParsedPanel(); if (ParsedPanel != null && ParsedPanel.IsValid()) { MessageSB.AppendLine("Solving route....."); DateTime dt = DateTime.Now; PadPanel FinalPanel = null; await Task.Factory.StartNew(() => { ParsedRoute = PuzzleSolver.SolvePuzzleLoop(ParsedPanel, 40, TargetRouteScore); FinalPanel = ParsedPanel.ApplyRoute(ParsedRoute); }); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ResultPanelTextBlock.Text = FinalPanel.ToString(); RouteTextBox.Text = ParsedRoute.ToString(); }); int timems = (int)(DateTime.Now - dt).TotalMilliseconds; MessageSB.Append("Score:"); MessageSB.Append(ParsedRoute.Score); MessageSB.Append(",len:"); MessageSB.AppendLine(ParsedRoute.Length.ToString()); MessageSB.Append("Finish in "); MessageSB.Append(timems.ToString()); MessageSB.AppendLine(" ms"); } }