Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Accesing timer from other thread

Accesing timer from other thread

Scheduled Pinned Locked Moved C#
winformsdesignhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Diego F
    wrote on last edited by
    #1

    Hello. I have a windows forms application that has some timers. One of these timers has a tick event that raises another thread to continue with the application. I did that because the next operations include listening to a socket, and the UI gets blocked. The problem is that in some occasions, I need to reactivate the timer, but it is not raised. I think it's because it's called from another thread. Any way to solve that?

    Regards, Diego F.

    R 1 Reply Last reply
    0
    • D Diego F

      Hello. I have a windows forms application that has some timers. One of these timers has a tick event that raises another thread to continue with the application. I did that because the next operations include listening to a socket, and the UI gets blocked. The problem is that in some occasions, I need to reactivate the timer, but it is not raised. I think it's because it's called from another thread. Any way to solve that?

      Regards, Diego F.

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      What you need is Control.Invoke[^]. Robert

      D 1 Reply Last reply
      0
      • R Robert Rohde

        What you need is Control.Invoke[^]. Robert

        D Offline
        D Offline
        Diego F
        wrote on last edited by
        #3

        Can you please tell me how to use Invoke to enable a timer?

        Regards, Diego F.

        R 1 Reply Last reply
        0
        • D Diego F

          Can you please tell me how to use Invoke to enable a timer?

          Regards, Diego F.

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          Something like this should work: timer.Invoke(new MethodInvoker(timer.Start)); Robert

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups