Activating timer from other thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Diego F.

    #1

    Activating timer from other thread

    Hello. I have a multi threaded application (I use threadpool). The main
    thread has some timers. In some circumstances, I need to activate one of
    these timers from other thread.

    I activate the timer with enabled property, but the tick event won't raise.

    What's the problem with that? Any solution?

    --

    Regards,

    Diego F.



  • Cor Ligthert [MVP]

    #2
    Re: Activating timer from other thread

    Diego,

    One of the main purposes from using threads is that they are not working
    synchonized but assynchroon.

    If you now want a synchronized assynchroon sollution, than you should look
    in my idea first to your solution. However just my idea.

    Cor

    "Diego F." <diego_frNO@msn .comschreef in bericht
    news:OZfB73QoHH A.716@TK2MSFTNG P05.phx.gbl...
    Hello. I have a multi threaded application (I use threadpool). The main
    thread has some timers. In some circumstances, I need to activate one of
    these timers from other thread.
    >
    I activate the timer with enabled property, but the tick event won't
    raise.
    >
    What's the problem with that? Any solution?
    >
    --
    >
    Regards,
    >
    Diego F.
    >
    >
    >

    Comment

    • Diego F.

      #3
      Re: Activating timer from other thread

      Sorry, I don't understand you. What do you mean by your idea?

      --

      Regards,

      Diego F.


      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
      news:%23BL4GpSo HHA.1220@TK2MSF TNGP03.phx.gbl. ..
      Diego,
      >
      One of the main purposes from using threads is that they are not working
      synchonized but assynchroon.
      >
      If you now want a synchronized assynchroon sollution, than you should look
      in my idea first to your solution. However just my idea.
      >
      Cor
      >
      "Diego F." <diego_frNO@msn .comschreef in bericht
      news:OZfB73QoHH A.716@TK2MSFTNG P05.phx.gbl...
      >Hello. I have a multi threaded application (I use threadpool). The main
      >thread has some timers. In some circumstances, I need to activate one of
      >these timers from other thread.
      >>
      >I activate the timer with enabled property, but the tick event won't
      >raise.
      >>
      >What's the problem with that? Any solution?
      >>
      >--
      >>
      >Regards,
      >>
      >Diego F.
      >>
      >>
      >>
      >
      >

      Comment

      • Andrew Christiansen

        #4
        Re: Activating timer from other thread

        Since you described using the 'Enabled' property on the timer, I see you're
        using System.Windows. Forms.Timer. This is not good to use in multi-threaded
        applications unless the timer is used entirely within the GUI thread (within
        the form which contains the timer). Rather, use System.Threadin g.Timer
        instead. It invokes a method of your choice asynchronously at the intervals
        specified. Also, you could consider utilizing Threading.Sleep within a loop
        on your thread to achieve timer like functionality.

        Best regards,
        Andrew

        "Diego F." <diego_frNO@msn .comwrote in message
        news:OZfB73QoHH A.716@TK2MSFTNG P05.phx.gbl...
        Hello. I have a multi threaded application (I use threadpool). The main
        thread has some timers. In some circumstances, I need to activate one of
        these timers from other thread.
        >
        I activate the timer with enabled property, but the tick event won't
        raise.
        >
        What's the problem with that? Any solution?
        >
        --
        >
        Regards,
        >
        Diego F.
        >
        >
        >

        Comment

        Working...