Exemplo n.º 1
0
        public void StartNewRace()
        {
            // When a race begins, remove a reference to the previous winner.
            if (RaceHorse.raceWinner != null)
            {
                RaceHorse.raceWinner = null;
            }

            // Put the horse back at the start of the track.
            this.PercentComplete = 0;

            // Give the horse a random "speed" to run at.
            this.timer.Interval = TimeSpan.FromMilliseconds(RaceHorse.random.Next(20, 100));

            // Start the DispatcherTimer, which ticks when the horse should "move."
            if (!this.timer.IsEnabled)
            {
                this.timer.Start();
            }
        }
Exemplo n.º 2
0
        public void StartNewRace()
        {
            // When a race begins, remove a reference to the previous winner.
            if( RaceHorse.raceWinner != null )
                RaceHorse.raceWinner = null;

            // Put the horse back at the start of the track.
            this.PercentComplete = 0;

            // Give the horse a random "speed" to run at.
            this.timer.Interval = TimeSpan.FromMilliseconds( RaceHorse.random.Next( 20, 100 ) );

            // Start the DispatcherTimer, which ticks when the horse should "move."
            if( ! this.timer.IsEnabled )
                this.timer.Start();
        }