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

Code before:
    const size_t TermControl::TaskbarProgress() const noexcept
    {
        return _core->TaskbarProgress();
    }

    void TermControl::BellLightOn()
    {
        // Initialize the animation if it does not exist
        // We only initialize here instead of in the ctor because depending on the bell style setting,
        // we may never need this animation
        if (!_bellLightAnimation)
        {
            _bellLightAnimation = Window::Current().Compositor().CreateScalarKeyFrameAnimation();
            // Add key frames and a duration to our bell light animation
            _bellLightAnimation.InsertKeyFrame(0.0, 2.0);
            _bellLightAnimation.InsertKeyFrame(1.0, 1.0);
            _bellLightAnimation.Duration(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(TerminalWarningBellInterval)));
        }

        // Similar to the animation, only initialize the timer here
        if (!_bellLightTimer)
        {
            DispatcherTimer invertTimer;
            invertTimer.Interval(std::chrono::milliseconds(TerminalWarningBellInterval));
            invertTimer.Tick({ get_weak(), &TermControl::_BellLightOff });
            _bellLightTimer = invertTimer;
        }

        Windows::Foundation::Numerics::float2 zeroSize{ 0, 0 };
        // If the grid has 0 size or if the bell timer is
        // already active, do nothing
        if (RootGrid().ActualSize() != zeroSize && !_bellLightTimer.IsEnabled())
        {
            // Start the timer, when the timer ticks we switch off the light
            _bellLightTimer.Start();

            // Switch on the light and animate the intensity to fade out
            VisualBellLight::SetIsTarget(RootGrid(), true);
            BellLight().CompositionLight().StartAnimation(L"Intensity", _bellLightAnimation);
        }
    }

    void TermControl::_BellLightOff(Windows::Foundation::IInspectable const& /* sender */,
                                    Windows::Foundation::IInspectable const& /* e */)
    {
        if (_bellLightTimer)
        {
            // Stop the timer and switch off the light
            _bellLightTimer.Stop();

            if (!_closing)

Review comment (performance):
Since you don't intend to further use `invertTimer` it's more efficient to do this:
```cpp
_bellLightTimer = std::move(invertTimer);
```

That way we don't increment the reference count in the assignment operator and then decrement it again when `invertTimer` is destroyed right after.

You can also write this though:
```cpp
_bellLightTimer = {};
_bellLightTimer.Interval(std::chrono::milliseconds(TerminalWarningBellInterval));
_bellLightTimer.Tick({ get_weak(), &TermControl::_BellLightOff });
```

Code after:
    const size_t TermControl::TaskbarProgress() const noexcept
    {
        return _core->TaskbarProgress();
    }

    void TermControl::BellLightOn()
    {
        // Initialize the animation if it does not exist
        // We only initialize here instead of in the ctor because depending on the bell style setting,
        // we may never need this animation
        if (!_bellLightAnimation)
        {
            _bellLightAnimation = Window::Current().Compositor().CreateScalarKeyFrameAnimation();
            // Add key frames and a duration to our bell light animation
            _bellLightAnimation.InsertKeyFrame(0.0, 2.0);
            _bellLightAnimation.InsertKeyFrame(1.0, 1.0);
            _bellLightAnimation.Duration(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(TerminalWarningBellInterval)));
        }

        // Similar to the animation, only initialize the timer here
        if (!_bellLightTimer)
        {
            _bellLightTimer = {};
            _bellLightTimer.Interval(std::chrono::milliseconds(TerminalWarningBellInterval));
            _bellLightTimer.Tick({ get_weak(), &TermControl::_BellLightOff });
        }

        Windows::Foundation::Numerics::float2 zeroSize{ 0, 0 };
        // If the grid has 0 size or if the bell timer is
        // already active, do nothing
        if (RootGrid().ActualSize() != zeroSize && !_bellLightTimer.IsEnabled())
        {
            // Start the timer, when the timer ticks we switch off the light
            _bellLightTimer.Start();

            // Switch on the light and animate the intensity to fade out
            VisualBellLight::SetIsTarget(RootGrid(), true);
            BellLight().CompositionLight().StartAnimation(L"Intensity", _bellLightAnimation);
        }
    }

    void TermControl::_BellLightOff(Windows::Foundation::IInspectable const& /* sender */,
                                    Windows::Foundation::IInspectable const& /* e */)
    {
        if (_bellLightTimer)
        {
            // Stop the timer and switch off the light
            _bellLightTimer.Stop();

            if (!_closing)
            {