Slow event execution

Hi Everyone

Me again… What is the normal cause in c# to slow down the system t snails pace.
Obviously Its my code but the code was derived from a class already written


 public craneview(Desktop window)
        {
            _window = window;

                              
            loopTimer = new DispatcherTimer();
            loopTimer.Tick += Loop;
            loopTimer.Interval = new TimeSpan(0, 0, 0, 0, 62); // 16 FPS
            loopTimer.Start();
        }

        /// <summary>
        /// Renders the screen bitmap initially.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnRender(DrawingContext dc)
        {
            dc.DrawImage(screen, 0, 0);
        }

        /// <summary>
        /// Loop that handles the game's logic.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Loop(object sender, EventArgs e)
        {
            if (exiting) return;
            if (ATB == 0)
                ATB = 1;
            else
                ATB = 0;
            messages = "ATB ON";
            if (ATB == 0)
                messages = "ATB OFF";                             
                          

            UpdateScreen();
        }

        /// <summary>
        /// Update the screen bitmap.
        /// </summary>
        private void UpdateScreen()
        {
            screen.Clear();
            screen.Scale9Image(0, 0, this.Width, 32, _task, 0, 0, 0, 0, 0xFF);
            screen.DrawImage(0, 32, uniccrane, 0, 0, uniccrane.Width, uniccrane.Height);
            screen.DrawText(angle.ToString("F1"), segoeFont, Color.Black, 5, 180);
            screen.DrawText(length.ToString("F1"), segoeFont, Color.Black, 200, 180);
            screen.DrawText(radius.ToString("F1"), segoeFont, Color.Black, 280, 240);
            screen.DrawText(messages, ninaBFont, Color.White, 5, 5);
            screen.DrawText(weight.ToString("F2"), segoeFont, Color.White, 360, 250);
            screen.DrawText(swl.ToString("F2"), segoeFont, Color.White, 360, 32);
            
            screen.Flush();
        }

When the button “select” is pressed or the touch screen is touched the events seem to pile up and run all at once ( the rest of the code is the same as the original demo code )

I Think personally that scaling the taskbar image is the culprit as when this is removed it runs a little better

All right don’t go there…

I would suppose running too much in a thread isn’t the best way to go. Obviously being a die hard pic man I should have noticed but I probably assumed a 72mhz system would run as fast as an AMD64…

Sorry about that. I’ll ditch the loop and have while(1) loop as there will a lot to do.

It did very well though full screen pictures and all one giff to be deoded aswell…

For those who viewed this and can’t see what happened the loop thread spilled over before the loop was completed. The longer it ran the worse it got, at one stage i had pressed the esc button 12 times in succession and waited about 2 minutes before it came back. BUT as the scape button was the select button it kept re-running.

Whoops.

Regards Ian

Those 72Mhz device we have are quite powerful, it is a matter of learning how to tweak your application to make things happen the way you want.