THE MAIN LOOP

For our applications we will use the structure of the figure:

You will find these files at the downloadable material of each lesson. You can load the .CSPROJ file at the Visual C# Express and press "Start Debugging" for a new compilation.

All the games need to have a "main loop" that will control many things. At this lesson we will only create a "loop" using the class DispatcherTimer.

In the line of code (look and analize all the code at the downloadable material - link at the bottom of this page):

 _timer.Interval = new System.TimeSpan(0, 0, 0, 0, 1000);
the number 1000 is the quantity of miliseconds between each run of the event:OnTimerEvent, that we will override.

The exercice will show the loop running and showing a counter:

To look the source codes and/or run the exercice, create a folder having the name of the .ZIP file and download it - right-clicking the link - and unzip inside the folder :

tu1s.zip

You can load the .CSPROJ in the Visual C# Express and to "compile" the application.

Try to recreate the exercice changing the code.

If you like only to see the application running you don't need to do the above download. Only liberate the firewall and play this web3d application:




PREVIOUS LESSON NEXT LESSON
T.CONTENTS HOMEPAGE