Repository: microsoft/terminal
File: src/cascadia/TerminalControl/TermControl.cpp (C++)

Code before:
                                                          panelHeight,
                                                          panelScaleX);
            if (!coreInitialized)
            {
                return false;
            }
            _interactivity.Initialize();
        }
        else
        {
            _core.SizeOrScaleChanged(panelWidth, panelHeight, panelScaleX);
        }

        _core.EnablePainting();

        auto bufferHeight = _core.BufferHeight();

        ScrollBar().Maximum(0);
        ScrollBar().Minimum(0);
        ScrollBar().Value(0);
        ScrollBar().ViewportSize(bufferHeight);
        ScrollBar().LargeChange(bufferHeight); // scroll one "screenful" at a time when the scroll bar is clicked

        // Set up blinking cursor
        int blinkTime = GetCaretBlinkTime();
        if (blinkTime != INFINITE)
        {
            // Create a timer
            DispatcherTimer cursorTimer;
            cursorTimer.Interval(std::chrono::milliseconds(blinkTime));
            cursorTimer.Tick({ get_weak(), &TermControl::_CursorTimerTick });
            _cursorTimer.emplace(std::move(cursorTimer));
            // As of GH#6586, don't start the cursor timer immediately, and
            // don't show the cursor initially. We'll show the cursor and start
            // the timer when the control is first focused.
            //
            // As of GH#11411, turn on the cursor if we've already been marked
            // as focused. We suspect that it's possible for the Focused event
            // to fire before the LayoutUpdated. In that case, the
            // _GotFocusHandler would mark us _focused, but find that a
            // _cursorTimer doesn't exist, and it would never turn on the
            // cursor. To mitigate, we'll initialize the cursor's 'on' state
            // with `_focused` here.
            _core.CursorOn(_focused || _displayCursorWhileBlurred());
            if (_displayCursorWhileBlurred())
            {
                _cursorTimer->Start();
            }
        }
        else
        {

Review comment (suggestion):
note to self: `Interval` will correctly re-initialize the underlying `Timer` if it was already `Destroy`'ed

Code after:
            {
                return false;
            }
            _interactivity.Initialize();
        }
        else
        {
            _core.SizeOrScaleChanged(panelWidth, panelHeight, panelScaleX);
        }

        _core.EnablePainting();

        auto bufferHeight = _core.BufferHeight();

        ScrollBar().Maximum(0);
        ScrollBar().Minimum(0);
        ScrollBar().Value(0);
        ScrollBar().ViewportSize(bufferHeight);
        ScrollBar().LargeChange(bufferHeight); // scroll one "screenful" at a time when the scroll bar is clicked

        // Set up blinking cursor
        int blinkTime = GetCaretBlinkTime();
        if (blinkTime != INFINITE)
        {
            // Create a timer
            _cursorTimer.Interval(std::chrono::milliseconds(blinkTime));
            _cursorTimer.Tick({ get_weak(), &TermControl::_CursorTimerTick });
            // As of GH#6586, don't start the cursor timer immediately, and
            // don't show the cursor initially. We'll show the cursor and start
            // the timer when the control is first focused.
            //
            // As of GH#11411, turn on the cursor if we've already been marked
            // as focused. We suspect that it's possible for the Focused event
            // to fire before the LayoutUpdated. In that case, the
            // _GotFocusHandler would mark us _focused, but find that a
            // _cursorTimer doesn't exist, and it would never turn on the
            // cursor. To mitigate, we'll initialize the cursor's 'on' state
            // with `_focused` here.
            _core.CursorOn(_focused || _displayCursorWhileBlurred());
            if (_displayCursorWhileBlurred())
            {
                _cursorTimer.Start();
            }
        }
        else
        {
            _cursorTimer.Destroy();
        }

        // Set up blinking attributes
        auto animationsEnabled = TRUE;