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. delay(windows application form)

delay(windows application form)

Scheduled Pinned Locked Moved C#
helptutorialquestion
6 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.
  • C Offline
    C Offline
    cishi_us
    wrote on last edited by
    #1

    I want to know a question from you that i want to apply a timer between my code. you help me please. means that for example i have two lines of code let say. console.writeline("hello1); console.writeline("hello2); Now i wana to do that after 10 seconds console.writeline("hello2) executes(not every 10 sec). console.writeline("hello1);; //timer of 10 sec// console.writeline("hello2); Means that when console.writeline("hello1) then after 10 sec console.writeline("hello2) should be executed.. Please help me ,, i m very near to my destiny. with regards Ishtiaq Ahmed

    Y D 2 Replies Last reply
    0
    • C cishi_us

      I want to know a question from you that i want to apply a timer between my code. you help me please. means that for example i have two lines of code let say. console.writeline("hello1); console.writeline("hello2); Now i wana to do that after 10 seconds console.writeline("hello2) executes(not every 10 sec). console.writeline("hello1);; //timer of 10 sec// console.writeline("hello2); Means that when console.writeline("hello1) then after 10 sec console.writeline("hello2) should be executed.. Please help me ,, i m very near to my destiny. with regards Ishtiaq Ahmed

      Y Offline
      Y Offline
      yoaz
      wrote on last edited by
      #2

      maybe this will help console.writeline("hello1); System.Timers.Timer t1 = new System.Timers.Timer(); t1.Interval = 10000; t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1); t1.AutoReset = true; t1.Enabled = true; and define the ont1 event handler: public static void ont1(object sender, System.Timers.ElapsedEventArgs e) { console.writeline("hello2); } there are no facts, only interpretations

      C 1 Reply Last reply
      0
      • C cishi_us

        I want to know a question from you that i want to apply a timer between my code. you help me please. means that for example i have two lines of code let say. console.writeline("hello1); console.writeline("hello2); Now i wana to do that after 10 seconds console.writeline("hello2) executes(not every 10 sec). console.writeline("hello1);; //timer of 10 sec// console.writeline("hello2); Means that when console.writeline("hello1) then after 10 sec console.writeline("hello2) should be executed.. Please help me ,, i m very near to my destiny. with regards Ishtiaq Ahmed

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You're not very specific about what your looking for, but you might want to try:

        console.writeline("hello1");
        Thread.Sleep(10000); // Sleep for 10 seconds...
        console.writeline("hello2");

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        C 1 Reply Last reply
        0
        • Y yoaz

          maybe this will help console.writeline("hello1); System.Timers.Timer t1 = new System.Timers.Timer(); t1.Interval = 10000; t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1); t1.AutoReset = true; t1.Enabled = true; and define the ont1 event handler: public static void ont1(object sender, System.Timers.ElapsedEventArgs e) { console.writeline("hello2); } there are no facts, only interpretations

          C Offline
          C Offline
          cishi_us
          wrote on last edited by
          #4

          sit this i have checked..its hapeening every 10 sec.but i need to do is that it should be executed 1ce after 10 sec. i.e eg when i cliked on button which have two message box,then after first messagebox ,second messagebox appears after 10 sec....in this case t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1); if i remove '+' then it can be possible but it cant. so i need to execute like this way

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You're not very specific about what your looking for, but you might want to try:

            console.writeline("hello1");
            Thread.Sleep(10000); // Sleep for 10 seconds...
            console.writeline("hello2");

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            C Offline
            C Offline
            cishi_us
            wrote on last edited by
            #5

            it simple. let say i have button on my form,,,,and i have two messageboxes on my button click..i need to do that when ever i click my button,1st message box appears and 2nd message box appears after 10 sec .

            1 Reply Last reply
            0
            • C cishi_us

              sit this i have checked..its hapeening every 10 sec.but i need to do is that it should be executed 1ce after 10 sec. i.e eg when i cliked on button which have two message box,then after first messagebox ,second messagebox appears after 10 sec....in this case t1.Elapsed += new System.Timers.ElapsedEventHandler(ont1); if i remove '+' then it can be possible but it cant. so i need to execute like this way

              S Offline
              S Offline
              Sebastian Schneider
              wrote on last edited by
              #6

              Im sorry to say this, but your problem might be that you dont understand how the timer works, maybe due to some problems with the English language. You should start looking up words you dont understand (like Timer.Enabled) instead of simply hacking in the lines. ENABLED is used to activate or deactivate the timer, though most of the time Stop() and Start() are the better choices. If you disable the timer (i.e. Timer.Stop() ) after the first elapsed-event, the timer will not "tick" again. Cheers Sid

              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