lolp1 / Overlay.NET

An easy-to-use overlay library written in C# by Jacob Kemple.
732 stars 87 forks source link

High CPU usage #7

Closed shatterr closed 7 years ago

shatterr commented 7 years ago

Hi, love the library - however when drawing just one text line over an application nothing else it uses around 30% CPU, is this normal or is something wrong!?

lolp1 commented 7 years ago

Using WPF or directx? Depending on your update rate and computer specs 30% does not sound impossible, but that seems extremely high to me.

shatterr commented 7 years ago

Using DirectX, set to 20fps --> have a pretty powerful PC so that's why it was suprising to me

lolp1 commented 7 years ago

Hello,

I have found the cause of cpu use being so high in the demo.

https://github.com/lolp1/Overlay.NET/blob/master/src/Overlay.NET.Demo/Wpf/WpfOverlayExampleDemo.cs#L86

Simply put, the update method is called with no Thread.Sleep so it consumes a lot of resources. Creating the WPF window in its own separate STA thread and calling the update with a Thread.Sleep(1) will reduce CPU usage from 25-30% to 1-5% :)