1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Difference between System.Windows.Forms.Timer and System.Timers.Timer

Discussion in 'C#' started by shabbir, Dec 4, 2006.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83

    System.Windows.Forms.Timer



    1. It's a forms-based timer.

    2. After creating it, you can set the interval which elapses between ticks using the Interval and hook up a delegate to its Tick event.

    3. Calling Start and Stop methods, start and stop of the timer.

    4. It runs entirely on the UI thread, So some of the UI related operations is to be done in this timers.

    5. Long UI operation may result in loosing some ticks

    System.Timers.Timer



    1. Instead of a Tick event, it has the Elapsed event.

    2. As before, 3. Calling Start and Stop methods, start and stop of the timer.

    3. The AutoReset property determines whether or not the timer should fire the event once and then stop, or keep going in a fire event / wait cycle. System.Windows.Forms.Timer does not have this property

    4. Setting the synchronizing object to a UI control makes the event fire on that control's UI thread.
     

Share This Page