Proper use of Task.Delay to delay key presses
===

The code below works for what i'm doing however I'm curious if my use of Task.Delay() is not best practice.  I need a delay to ensure that the GameHandler has enough time to process my Key presses.  However, i'm wondering if there is a better approach to doing something like this.

 

    async public Task<bool> CloseMenusAsync(CancellationToken token)
                {
                    while (GameHandler.Menu.IsOpen && !token.IsCancellationRequested)
                    {
                        if (GameHandler.Menu.IsOpen && GameHandler.Menu.DialogText.Question == "Open")
                        {
                            GameHandler.SendKeyPress(KeyCode.DownArrow);
                            await Task.Delay(150);
                            GameHandler.SendKeyPress(KeyCode.EnterKey);
                            await Task.Delay(150);
                        }
                        if (GameHandler.Menu.IsOpen && GameHandler.Menu.Selection == "Trade")
                        {
                            GameHandler.SendKeyPress(KeyCode.EscapeKey);
                            await Task.Delay(150);
                            GameHandler.SendKeyPress(KeyCode.EnterKey);
                            await Task.Delay(150);
                        }
                        GameHandler.SendKeyPress(KeyCode.EscapeKey);
                        await Task.Delay(150);
                    }
        
                    return !GameHandler.Menu.IsOpen;
                }