System.Timers.Timer Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?WWVuZXI=?=

    System.Timers.Timer Question

    I have strange situation on a Framework 2.0 windows service.
    Here is elapsed event of the timer. There is breakpoint1 on Start_Process() .
    if i work too long debugging Start_process function or forget and go for a
    tea. Debugger hits the breakpoint2 inside the finally block. How come could
    this happen?

    private void timer1_Elapsed( object sender, System.Timers.E lapsedEventArgs e)
    {
    try
    {

    timer1.Enabled = false;
    Start_Process() // BreakPoint 1
    }
    catch (System.Excepti on Ex)
    {

    //Do exception handling
    }
    finally
    {
    timer1.Interval = GetTimerInterva l(); // BreakPoint 2
    timer1.Enabled = true;
    }
    }


    thnks
  • Israel

    #2
    Re: System.Timers.T imer Question

    Are you sure that there aren't actually two threads comming in and
    then when you step into Start_Process() on one thread the other thread
    is just running through that and ending up at the finally block.
    That's my only thought since the timer events come in on arbitrary
    thread pool threads and, unlike the UI timer, will just keep coming
    until you eat up your thread pool.


    Comment

    • =?Utf-8?B?WWVuZXI=?=

      #3
      Re: System.Timers.T imer Question


      I am running whole solution in my local machine. Under normal
      circumstances,i t is not possible that another thread would run while timer
      is disabled. There is a windows service that make use of web services and
      more than 60 other projects on business and db layers. It was also hard to
      prepare the system for debugging. Sometimes , strange things are happening, i
      dunno why.

      "Israel" wrote:
      Are you sure that there aren't actually two threads comming in and
      then when you step into Start_Process() on one thread the other thread
      is just running through that and ending up at the finally block.
      That's my only thought since the timer events come in on arbitrary
      thread pool threads and, unlike the UI timer, will just keep coming
      until you eat up your thread pool.
      >
      >
      >

      Comment

      Working...