I just got started with async functions and am running into mainthread block. What part of my code causes this? Any help would be appreciated
//mainthread function
private void ShortestPathBetweenNodes(Node start , Node)
{
RunDijkstraAsync(start, target);
}
async void RunDijkstraAsync(Node start, Node target)
{
List<Node> path = new List<Node>();
path = await DijkstrAsync(start, target);
}
async Task<List<Node>> DijkstrAsync(Node start, Node target)
{
await Task.Run(() =>
{
//omitted function code. markedNode.previous is the List<Node> to return
return markedNode.previous;
});
}
I expected this to run async on a non-mainthread, but it blocks the mainthread regardless.