Invalidate() is so consuming

I have been using simpleglcontrol to create a simple 3D animation. everything seemed nice unless I checked the memory and cpu usage. the memory and cpu usage were too high compared to using freeglut scenes. This is sure because of using Invalidate method. is there any suggestion to redraw the scene without using so much cpu and memory?

Hook the Application.Idle

Hook the Application.Idle event and loop there.

P/Invoke PeekMessage to see if you should exit the loop for event processing (it will be resumed automatically as soon as all messages have been processed).

Invalidate has high overhead and may allocate memory.

------
OpenTK

Hello StApostol, I'm facing

Hello StApostol,
I'm facing the same issue and I have set up the Application.Idle event as suggested. However now the system's CPU is always at 100% when idle. Do you have an idea how to avoid that behaviour ?
Thanks a lot !

Use

Use System.Threading.Thread.Sleep(...), where "..." is a suitable value >= 1.

Do note that the sleep function does not guarantee how long the thread will sleep - it only guarantees that it will sleep at least the number of milliseconds you specified, so be careful you don't overshoot your target frame time.

------
OpenTK

Thanks a lot for your reply

Thanks a lot for your reply ! Does it have merit to use multi-threading to avoid this situation ?

Theme by La Boite a site | Powered by Drupal