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