Hello everyone!
I know how to use a Timer class:

static void Main(string[] args)
        {
            System.Timers.Timer MyTimer = new System.Timers.Timer();
            MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(MyTimer_Elapsed);
            MyTimer.Interval = 2000;
            MyTimer.Enabled = true;
            //etc.
        }

        static void MyTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            //do something every 2 seconds
        }

What I like to do is draw something every 2 secs during a draw method in a loop like:
>while condition true
> Draw object
> Wait 2 secs
>end loop after condition false

I could use a very long empty for loop as a wait method, is there a better way?
Have looked around here and there but found nothing usefull.
Any help (as always) is greatly appreciated:)

If you don't mind that the thread will halt for 2 seconds, you can use Thread.Sleep(2000).

commented: you got it +5

Thanks DdoubleD!
That really helps. I was probably looking for the wrong words like pause and wait.:idea:

Thanks DdoubleD!
That really helps. I was probably looking for the wrong words like pause and wait.:idea:

I actually had flashbacks of that same thinking in the past... I was just hoping it was that simple.:P

Thanks to Intellisence I was even able to figure out I needed using System.Threading; Thanks again D!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.