Tutorial FAQ

Why are you using objects/classes?

The sample applications use 100% of my CPU, why don't you use a timer?

Why are you using objects/classes?

C# and VB.Net are natively Object Oriented languages and Managed DirectX was designed to be used that way. Trying to do anything else would require a lot of effort for no gain. The majority of the people who read these tutorials will want to design their applications in an OOP fashion so it makes sense to embrace it.

The sample applications use 100% of my CPU, why don't you use a timer?

The Windows timers are low resolution and unreliable. You will not be able to reliably maintain a presentation rate of 60 frames per second using those timers.

Realistically, any running task that doesn't sleep will use all the available CPU time. That's the way it should work. All idle cycles are given to running tasks. Granted it may be hard to use your word processor while running my applications, but why would you want to do that anyway?

If you feel strongly about throttling your apps back, feel free to experiment with timers and add calls to Thread.Sleep().

NOTE: Using high resolution timers to wait until a certain amount of time has passed is just as bad since it busy waits. If you're going to use the cycles anyway, you might as well use them rendering rather than waiting. For "proper" waiting, use something like calls to Thread.Sleep() or System.Windows.Forms.Timer.

Back