C# background worker and timer loop

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-04-05T18:19:00Z Indexed on 2010/04/05 18:23 UTC
Read the original article Hit count: 136

Filed under:

This is my first attempt of a Timer, if someone could help me out where I am going wrong it would be awesome.

I'm trying to use a while loop where if the timer hits 30 seconds try to loop it again.

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        System.Windows.Forms.Timer my_timer = new System.Windows.Forms.Timer();
        my_timer = null;
        //int restartticker = 30000;
        while (true)
        {
            my_timer.Start();
            if (my_timer.Equals(30000))
            {
                watcherprocess1();
            }
            my_timer = null;
        }
    }

Object reference not set to an instance of an object. my_timer.Start();

© Stack Overflow or respective owner

Related posts about c#