![]() |
|
[C#] Timers - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Timers (/showthread.php?tid=5224197) |
Timers - colja123 - Apr 2, 2016 How can you use this: Timer myTimer = new Timer(); myTimer.Interval(); myTimer.Start(); What using directives am I suppost to insert? * - God - Apr 2, 2016 I don't really understand what your question is but I have an idea of what you mean. You can use buttons to stop or start the timer, and in the timer itself you can have code. This will just be a small program to actually time something (stopwatch with interval of 1second). 1) In the timer's interval set it to 1000 (1000 = 1sec) 2)In Timer Code Textbox1.Text = Textbox1.Text + 13)In Buttons Code timer1.start() and timer1.stop()Hopefully this helps, keep in mind this is a very basic example. * - Odus - Apr 2, 2016 It's part of System.Windows.Forms. I'm assuming this is a console project since you're having to ask this so you'll need to add it as a reference. * - colja123 - Apr 2, 2016 (Apr 2, 2016 11:49 AM)Odus Wrote: It's part of System.Windows.Forms. I'm assuming this is a console project since you're having to ask this so you'll need to add it as a reference. Thank you! Can you take a look at this code at paste bin? pastebin.c o m/EmD38RKH Why isn't it working? I don't get the mail with the logs! * - Hawk HF - Apr 2, 2016 (Apr 2, 2016 11:49 AM)Odus Wrote: It's part of System.Windows.Forms. I'm assuming this is a console project since you're having to ask this so you'll need to add it as a reference. You could also use the System.Timers.Timer class. That way you wouldn't need to carry around the extra weight from System.Windows.Forms. 🤝 * - Odus - Apr 2, 2016 (Apr 2, 2016 01:09 PM)Hawk HF Wrote: You could also use the System.Timers.Timer class. That way you wouldn't need to carry around the extra weight from System.Windows.Forms. Very true, I forgot there are like 5 implementations of the timer. * - colja123 - Apr 3, 2016 Guys, why's this not working? I made this: System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); t.Interval = 10000; // specify interval time as you want t.Tick += timer_Tick; t.Start(); static void timer_Tick(object sender, EventArgs e) { sendMail(); //this is the mail sending method } When I open it, it immediately closes... It should work though! * - GuRuHaX - Apr 3, 2016 Here are 4 examples in a console app solution i just tested them all , They all use a different way to implement a timer. Choose the one you find more easy . http://www115.zippyshare.com/v/YttBNdU1/file.html EDIT : VirusScan : https://www.virustotal.com/nl/file/f62b6feb5da2feb1cd0a0a7b81344b15ee4961dc39db3d4f229c358d2b30d3c1/analysis/1459673497/ 🤝 |