How to recalculate the path if aiPath.pathPending==true

i’ve set aiPath.autoRepath.mode = AutoRepathPolicy.Mode.Never; and manually search the path for my agent. I’ll invoke the StartSearch to recalculate the path after graph is changed. and if currently a path is being calculated then I’ll set needSearchAgain=true so that when the path is completed I’ll calculate it again by delegate of TrySearch(). the problem is sometimes when the callback function is invoked the aiPath.pathPending==true. so what’s the best way to recalculate the path for aiPath.pathPending == true

private bool needSearchAgain;

seeker.pathCallback += TrySearch; 

private void TrySearch(Path ignore)
        {
            if (needSearchAgain)
            {
                Assert.IsFalse(aiPath.pathPending);
                needSearchAgain = false;
                aiPath.SearchPath();
            }
        }

protected void StartSearch()
        {
            if (aiPath.pathPending)
            {
                needSearchAgain = true;
            }
            else
            {
                aiPath.SearchPath();
            }
        }

Hi

If you call aiPath.SearchPath while pathPending is true, then the current path calculation will be aborted and a new one started, this is fine as long as you don’t do graph updates too often so that a lot of path calculations are wasted.