[Solved] Stop executing next method for certain amount of time.

Hi, i am creating a logical game in match 3 style.
i have a method, which is checking lines, when a line is found, the animation is displaying. But when i am displaying that animation, and a new object is coming in that place, where the animation is displaying, i got some bug. So because i wanted to stop executing the next method for certain amount of time, by using enum.
But because is checking for it in a while loop, and the state of enum is changing by an invoke or a coroutine, the while loop in next method is going infinite.

if (!isLineFounded)
        {
            gameState = GameStates.AnimationPlaying;
            StartCoroutine(ResetGameState());
        }
 while(gameState == GameStates.AnimationPlaying)
            {
                Debug.Log("Can't add");
            }

So my question, what is a good way to solve problem, when i want to stop executing a method for certain amount of time. And why a coroutine is not changing it’s state during the above loop.

Sry for any language mistakes.

Thanks for any help in andvance.

Could you post your coroutine? also you could use a coroutine to wait for a certain amount of time or for the next fixed frame.

Here it’s the coroutine :

private IEnumerator ResetGameState()
    {
        yield return new WaitForSecondsRealtime(1);
        gameState = GameStates.NoneSelected;
    }

I can use coroutine to execute the next method but i got a problem that in summary that every each method have to wait for the end of previous one, when i am not getting that i got this bug.

public void AddShapesAndCheckForLines()
    {
        for (int i = 0; i < StartNumberOfShapesOnGrid; i++)
        {
            AddShapeAndCheckForLines();
        }

        gameState = TileGrid.GameStates.NoneSelected;
    }

    private void AddShapeAndCheckForLines() {
        Tile recentlyAdded = AddShapeToGrid();
        CheckForLines(recentlyAdded);
    }

The couroutine is starting in CheckForLines method so, then the AddShapeToGrid can wait for the animation time displaying.

I solved this by using coroutines and recursion, here it’s example :

public void AddShapesAndCheckForLines()
    {
        AddShapeAndCheckForLines(0,StartNumberOfShapesOnGrid);
        gameState = TileGrid.GameStates.NoneSelected;
    }

    private void AddShapeAndCheckForLines(int currentIndex, int maxIndex) {
        if (currentIndex < maxIndex) {
            Tile recentlyAdded = AddShapeToGrid();
            if (CheckForLines(recentlyAdded))
                StartCoroutine(LaunchMethodAfterTime(currentIndex+1,maxIndex));
            else
                AddShapeAndCheckForLines(currentIndex + 1, maxIndex);
        }             
     
    }

 private IEnumerator LaunchMethodAfterTime(int currentIndex, int maxindex)
    {
        yield return new WaitForSecondsRealtime(1);

        AddShapeAndCheckForLines(currentIndex, maxindex);
    }