sharpgl icon indicating copy to clipboard operation
sharpgl copied to clipboard

DispatchTimer Priority for drawing in OpenGLControl

Open ThVoss opened this issue 9 years ago • 3 comments

Hi,

Our users complained about a poor performance of our application when an OpenGLControl was open.

I tracked that down to the Dispatch timer priority which was 10 (DispatcherPriority.Send) which is the highest priority.

I lowered that priority to 7 (DispatcherPriority.Render). Doing this, reduces fps a little bit, but the rest of the application stays responsive.

Maybe that should be changed in the next Version?!

Cheers Thomas

ThVoss avatar Jun 11 '15 16:06 ThVoss

Hi,

just as an addition to this issue:

If you add multiple controls to to your application, which are used at the same time, even the DispatcherPriority.Render might cause the application to freeze, especially when the time needed in the draw handler * the number of controls exeeds the break time (1000/Frames in ms).

I've reduced the priority to DispatcherPriority.ApplicationIdle which still works fine for me.

Cheers Thomas

ThVoss avatar Jun 12 '15 13:06 ThVoss

Hi ThVoss, can you tell me where I can find the priority setting?

Thanks Davide

davidedec avatar Oct 13 '15 17:10 davidedec

Sure,

you can find that Setting in SharpGL.WPF.OpenGLControl.cs in the OnApplyTemplate method.

Just Change: timer = new DispatcherTimer(DispatcherPriority.Render); to: timer = new DispatcherTimer(DispatcherPriority.ApplicationIdle); or: timer = new DispatcherTimer(DispatcherPriority.SystemIdle);

Cheers

Thomas

ThVoss avatar Oct 14 '15 07:10 ThVoss