wpfsvl icon indicating copy to clipboard operation
wpfsvl copied to clipboard

DispatcherTimer priority

Open ThuCommix opened this issue 8 years ago • 0 comments

Hello, I have a very large application, and the animation of the spectrum analyzer laggs because the priority of the dispatcher timer is only ApplicationIdle. If I change it to Render via Reflection it's smooth again.

Can you make this configurable without using reflection?

Current workaround:

` var spectrumAnalyzerType = spectrumAnalyzer.GetType(); var dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render) {Interval = TimeSpan.FromMilliseconds(spectrumAnalyzer.RefreshInterval)}; var animationTimerField = spectrumAnalyzerType.GetField("animationTimer", BindingFlags.Instance | BindingFlags.NonPublic); var tickMethodInfo = spectrumAnalyzerType.GetMethod("animationTimer_Tick", BindingFlags.Instance | BindingFlags.NonPublic); var tickEventInfo = typeof(DispatcherTimer).GetEvent("Tick");

        animationTimerField.SetValue(spectrumAnalyzer, dispatcherTimer);
        var handler = Delegate.CreateDelegate(tickEventInfo.EventHandlerType, spectrumAnalyzer, tickMethodInfo);
        tickEventInfo.AddEventHandler(dispatcherTimer, handler);


        spectrumAnalyzer.RegisterSoundPlayer(...);`

ThuCommix avatar Oct 26 '17 19:10 ThuCommix