abt system.threading.timer

Hi
I want to read abt sytem.threading.timer....
I had a look on several examples and articles in many sites and MSDN..but i dont have any clear idea abt it.
so please explain me, wht is use of system.threading.timer and its uses.
and also explain abt new timercallback()
. please explain me clearly, ...

batista




Answer this question

abt system.threading.timer

  • masterbuyerseller

    I am beginning a new app with two threads: a processing thread and a display thread. Each thread has an independent system.threading.timer to control processing. It all works, but after about 10 seconds, they both stop firing. Is there a parameter that I need to set to keep the timers going indefinitely Could the garbage collector be gobbling them up Do I need to recreate the timers periodically

    Any help is greatly appreciated.

    Thanks.

    bg


  • Caga

    From MSDN:System.Threading.Timer is a simple, lightweight timer that uses callback methods and is served by threadpool threads.

    If you wanted something to happen on a regular basis, you use this.  A TimerCallback is a delegate to specify what you want the timer to execute.  Say in the following example, the method Foo(object state) will be called once every 20 seconds.

    Timer t = new Timer(new TimerCallback(Foo), null, 0, 20 * 1000);

    HTH


  • abt system.threading.timer