Timer does not produce a callback thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marom27
    New Member
    • Mar 2010
    • 1

    Timer does not produce a callback thread

    Hi,

    I have a service (WCF) that uses timers to make some operations periodically.
    Generally everything work fine.
    But sometimes, when I use the Visual Stiudio 2008 debugger, and stop the debugger and reactivate it, altough the timers are initialized, they are not create their callback threads.

    piece of code for example that initializes the timers :

    Code:
       if (this.timer1 == null)
              this.timer1 = new System.Timers.Timer
                  SharedDataTypes.Constants.GENERAL_ONE_SECOND);
        this.timer1 .Enabled = true;
        this.timer1.Elapsed -= new System.Timers.ElapsedEventHandler
                                    (timer1_Elapsed);
         this.timer1.Elapsed += new System.Timers.ElapsedEventHandler
                                  (timer1_Elapsed);
         this.timer1.Stop();
         this.timer1.Start();
    All the timers are initialized similarly.

    Please tell me why they are not creates their callback thread, and how to fix it,
    so that they will alays create their callback thread.

    Thanks
    Michael
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    My guess is that you're aren't killing those threads when the application quits. Start your program. let is run a bit. Then close it. Now look in Task Manager under processess and see if you still have threads named for your application.

    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    Working...