RE: CPU performance rises when I'm opening an other application/dialog



Goodness those other "answers" were about as half baked as you can get. I've
seen the exact same problem you're experiencing and have a templated solution
I use on each app now. Consider the following game loop...

while (form.Created)
{
if (form.WindowState != FormWindowState.Minimized)
{
//Update our game, and render to screen
form.Render();
Thread.Sleep(1);
}
else
{
Thread.Sleep(300);
}
Application.DoEvents(); //Let the OS handle what it needs to
}

form is my directx window. form.Render() calls a bunch of objects that know
how to render themselves. The interseting part is the Thread.Sleep(1) line.
This little sleep period causes the app to release system resources and cut
my "background mode" cpu utililization from +80% to < 1%. In a real app.
You'd likely have a variable whose value changes based on the actual render
time of your app, this would become your fps lock if you wanted to lock your
fps to 60fps or whatever. Either way, without the sleep, you're app will run
as fast as possible and utilize as much cpu as is available (why this only
happens when the app is in background mode, is still a mystery to me).




"Wilfried Hafner" wrote:

> Hi!
>
> My application with a direct3d device needs only about 01 - 02% of
> cpu performance, but if I call a dialoge from the same application
> the cpu performance rises up to 50%.
> This happens also, when I'm opening an other application like
> fireworks or something at the same time...
> I'm rendering the Data in the OnPaint - Event...
>
> Thanks Willi
>
.



Relevant Pages

  • Re: CPU performance rises when Im opening an other application/dialog
    ... > I use on each app now. ... animation when the form is not in the foreground, and only call your Render ... > wanted to lock your fps to 60fps or whatever. ... reflect the official views of the Microsoft Corporation. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: CPU performance rises when Im opening an other application/dialog
    ... reflect the official views of the Microsoft Corporation. ... >> I use on each app now. ... > Render function when a Paint event is received. ... > Microsoft DirectX MVP ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: How multithreaded is Direct3D 9?
    ... Here's the calling sequence minus ... I use a simple offscreen plain surface because the docs say that the ... RenderToSurface code will create an appropriate render target and copy the ... > your app it doesn't seem like a huge problem if it happens once a minute. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Arabic Text Rendering
    ... > when the arabic text is passed to the method drawString in class ... See if this little app. ... render this text backwards, but since it is Swing based, ...
    (comp.lang.java.programmer)