running threading method periodically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vsrprasad16
    New Member
    • Oct 2007
    • 3

    #1

    running threading method periodically

    Hi All,
    Am new to threading concepts.
    i want to start a thread with a method DoProcess and run this method periodically at some time interval. for this i implemented like below.

    public void startWatcher(bo ol setTimer)
    {
    TimerCallback timerdelg = new TimerCallback(s tart);
    tmr = new Timer(timerdelg , null, 8000, 60000);
    }

    void start()
    {
    waitOnThread();
    watcherThread = new Thread(new ThreadStart(thi s.CheckOrderSta tus));
    watcherThread.I sBackground = true;
    watcherThread.N ame = "OrderStatusWat cher";
    watcherThread.S tart();
    }

    but this will create thread for each timer interval.
    How to start thread once and run that method continiusly until user stops the thread.?.

    Could some body put light on me.

    thanks for your time.,

    Rgds,
    vsr
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    System.Threadin g.Timer will create a thread, do what it's supposed to then kill the thread. And then repeat on a certain interval until you tell it to stop.
    This is not what you want?

    Comment

    Working...