private void CalculatePath(MovementBehavior per) { Trace.WriteLine("calculating path"); LayerTile start = map.GetTileByWorldPosition(selectedWO.GetCenteredPosition()); WaveServices.TaskScheduler.CreateTask(async() => { List <LayerTile> dPath = AStar.Astar(currentTile, start); Trace.WriteLine("path: " + dPath.Count.ToString()); await WaveServices.Dispatcher.RunOnWaveThread( () => { if (!selectedWO.IsDestroyed() && !selectedWO.IsActionBlocking()) { SendPath(dPath); } } ); }); }