How to tell if yielded function still running?

I am working on pathfinding, and I have it working fine, if I don’t yield in the function.

I have a function called FindMoves that loops through on a breadth-first search, and calls an A-Star routine on the open list items.

There’s not a huge lag, only a 1.0-1.5 second pause, but I would like to be able to yield, to avoid the pause.

The problem I have is that if I yield in the A-Star function, the FindMoves function runs through to the end, and performs all the clean up before all the pathing is done.

I’ve tried adding to a counter at the beginning of the A-Star, and subtracting when done, but this variable never goes over 1 for some reason, and the first path that finishes moves it down to 0.

Edit:
adding code below.

My problem is this: if I yield at any point in this function, or in the AStar function that gets called, the portion of this code after the line

 PathingCompleted = true;

Gets executed before all the paths are calculated, and of course, that screws up the code that comes at the end, which finds all the valid paths.
You can’t do that while the paths are still being created, as the move cost will be shown too low, including hexes in the Final set which should not be there.
I can’t even put this part into a new function and call it after FindMoves in the function that called it originally, it still runs through FindMoves and out before all the paths are run.

Now, I went from 10-12 seconds to run this function to a second and a half by making my AStar run all paths in parallel, but I still don’t want it to be completely frozen, even for that brief time.
If I can somehow yield and allow this to run in the background, I can cover the minor pause with a camera slide.

(EDIT: Deleted huge code block, because it ended up not being applicable)

When you call FindMoves, are you calling it as a coroutine, like “StartCoroutine(“FindMoves”);”?

I’ve had a few instances where coroutines were not yielding as expected, and it was usually because I forgot to use StartCoroutine instead of calling the function directly.