UI Automation retrieve incorrect children list of Windows 10 calculator application

  .net-core, c++, ui-automation, windows

We would like to use UI Automation to automate windows 10 calculator.
We found out that sometimes we are not getting the correct number of children with findAll method.
We wrote small application that check every second the number of children and write it to the console:

        static void Main(string[] args)
            var condition = new AndCondition(
                            new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window),
                            new PropertyCondition(AutomationElement.NameProperty, "Calculator"));
            var calculatorAutomationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, condition);
            while (true)
                var all = calculatorAutomationElement.FindAll(TreeScope.Children, Condition.TrueCondition);

The output of this application is 1 or 4 randomly.
Any suggestions?

Source: Windows Questions