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. Stop timer

Stop timer

Scheduled Pinned Locked Moved C#
question
4 Posts 4 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
    andredani
    wrote on last edited by
    #1

    Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(

    M G 2 Replies Last reply
    0
    • A andredani

      Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello,

      andredani wrote:

      My question is how do i stop the timer with a button2 click???

      You found the "Start()" method, but not the "Stop()" method. :confused: Anyway, you could also set the Boolean "Enabled" property "true" or "false"!

      andredani wrote:

      And do u know any good sleep or wait function???

      "Thread.Sleep(timeinms)" will freeze the thread (Also GUI if it's the main thread). Hope it helps!

      All the best, Martin

      1 Reply Last reply
      0
      • A andredani

        Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        You can use Enabled property for System.Timer or for System.Windows.Form.Timer

        andredani wrote:

        And do u know any good sleep or wait function???

        Is it very difficult to guess that 'sleep' function is called Sleep()?

        #region signature my articles #endregion

        B 1 Reply Last reply
        0
        • G Giorgi Dalakishvili

          You can use Enabled property for System.Timer or for System.Windows.Form.Timer

          andredani wrote:

          And do u know any good sleep or wait function???

          Is it very difficult to guess that 'sleep' function is called Sleep()?

          #region signature my articles #endregion

          B Offline
          B Offline
          blackjack2150
          wrote on last edited by
          #4

          Giorgi Dalakishvili wrote:

          Is it very difficult to guess that 'sleep' function is called Sleep()?

          Well, it might very well have been called "delay". :)

          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