C#WPF异常CPU使用率动画 [英] C# WPF abnormal CPU usage for animation

查看:1293
本文介绍了C#WPF异常CPU使用率动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发WPF应用程序和客户端报告extreamly高CPU使用率(90%)(而我无法重复的行为)。我已经追查bootleneck到这些行。这是简单的发光动画小单led控制(LED闪烁)。可能是什么原因简单annimation占用了如此巨大的CPU资源?

 <触发属性=国家>
            < Trigger.Value>
                <局部:BlinkingLedStatus>&闪烁LT; /地方:BlinkingLedStatus>
            < /Trigger.Value>
            < Trigger.EnterActions>
                < BeginStoryboard NAME =beginStoryBoard>
                    <情节提要>
                        < D​​oubleAnimation是Storyboard.TargetName =发光Storyboard.TargetProperty =透明度自动翻转=真从=0.0为了=1.0时长=0:0:0.5的repeatBehavior =永远/>
                    < /故事板>
                < / BeginStoryboard>
            < /Trigger.EnterActions>
            < Trigger.ExitActions>
                < StopStoryboard BeginStoryboardName =beginStoryBoard/>
            < /Trigger.ExitActions>
        < /触发>


解决方案

有机会,你的客户端没有硬件accelleration。各国(甚至昨天)图形卡应该是足以使WPF。告诉他更新他的图形驱动程序。您也可以通过设置 Timeline.DesiredFrameRate =20调整你的动画一点点(或更低,如果它适合你)在你的故事板。

I am developing WPF application and client reports extreamly high CPU usage (90%) (whereas i am unable to repeat that behavior). I have traced bootleneck down to these lines. It is simple glowing animation for small single led control (blinking led). What could be reason for this simple annimation taking up SO huge CPU resources?

         <Trigger Property="State"> 
            <Trigger.Value> 
                <local:BlinkingLedStatus>Blinking</local:BlinkingLedStatus> 
            </Trigger.Value> 
            <Trigger.EnterActions> 
                <BeginStoryboard Name="beginStoryBoard"> 
                    <Storyboard> 
                        <DoubleAnimation Storyboard.TargetName="glow" Storyboard.TargetProperty="Opacity" AutoReverse="True" From="0.0" To="1.0" Duration="0:0:0.5" RepeatBehavior="Forever"/> 
                    </Storyboard> 
                </BeginStoryboard> 
            </Trigger.EnterActions> 
            <Trigger.ExitActions> 
                <StopStoryboard BeginStoryboardName="beginStoryBoard"/> 
            </Trigger.ExitActions> 
        </Trigger> 

解决方案

Chances are that your client does not have hardware accelleration. Todays (and even yesterdays) graphics cards should be sufficient to render WPF. Tell him to update his graphics drivers. You can also tune your animation a little bit by setting Timeline.DesiredFrameRate="20" (or lower if it suitable for you) on your StoryBoard.

这篇关于C#WPF异常CPU使用率动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆