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. Timer tick problem

Timer tick problem

Scheduled Pinned Locked Moved C#
helpquestion
2 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.
  • A Offline
    A Offline
    Aviv Halperin
    wrote on last edited by
    #1

    Hi, I have a timer that I want to run in the main frame of my windows HMI application to execute a complex operation. I chose a System.Windows.Forms.Timer timer so that it'll run on the main application thread. I added a tick event : this.timerPlot.Tick += new System.EventHandler(this.timerPlot_Tick); and the timer woks fine on calls to timerPlot.Start() and timerPlot.Enable=true. But... when I try to start the timer from a seperate thread in the application the timer function timerPlot_Tick is never called!!! Does anyone know the reason why a timer can not be started from a sperate thread? Thanks. avivhal

    S 1 Reply Last reply
    0
    • A Aviv Halperin

      Hi, I have a timer that I want to run in the main frame of my windows HMI application to execute a complex operation. I chose a System.Windows.Forms.Timer timer so that it'll run on the main application thread. I added a tick event : this.timerPlot.Tick += new System.EventHandler(this.timerPlot_Tick); and the timer woks fine on calls to timerPlot.Start() and timerPlot.Enable=true. But... when I try to start the timer from a seperate thread in the application the timer function timerPlot_Tick is never called!!! Does anyone know the reason why a timer can not be started from a sperate thread? Thanks. avivhal

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      As MSDN states: "This Windows timer is designed for a single-threaded environment where UI threads are used to perform processing. It requires that the user code have a UI message pump available and always operate from the same thread, or marshal the call onto another thread." Use one of the other two Timer types. Here you find a short overview on timers.


      www.troschuetz.de

      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