XamlAnimatedGif / XamlAnimatedGif

A simple library to display animated GIF images in WPF apps (.NET Framework 4.5, .NET Core 3.1, .NET 5.0)
Apache License 2.0
434 stars 77 forks source link

Save CPU #204

Open Farb opened 4 weeks ago

Farb commented 4 weeks ago

Is your feature request related to a problem? Please describe. No.

Describe the solution you'd like I hope that gif image is working when the window is in foreground, and not working when in background. If not so,the CPU is always is always working when the window is in background. My code is as following:

<Image gif:AnimationBehavior.SourceStream="{Binding OriginStream,IsAsync=True}">

Describe alternatives you've considered I set the Visibility="Collapsed" in the Image control, but it is ineffective.

Additional context

I profiled the issue in the DotMemory tool.I found GC had been working all the time.

thomaslevesque commented 4 weeks ago

Hi @Farb, Sounds like a good idea! This behavior should probably be optional, though. To be honest, I don't have much spare time to work on this feature, so don't hold your breath. If you feel like giving it a try yourself, a PR would be welcome. In the meantime, you can always subscribe to window events to detect when the window loses focus, and programmatically stop the animation.