Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Timers

How can you use this:

Timer myTimer = new Timer();
myTimer.Interval();
myTimer.Start();

What using directives am I suppost to insert?
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 + 1

3)In Buttons
Code
timer1.start() and timer1.stop()

Hopefully this helps, keep in mind this is a very basic example.
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.
(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!
(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.
🤝
(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.
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!
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/f62b6...459673497/

🤝


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bora or HyunaJan 27, 2020 12:26 PM 6 179 Jan 27, 2020 12:26 PM
Last Post: Lindros
[.NET] by selfieman231Dec 11, 2016 04:22 PM 5 155 Dec 11, 2016 04:22 PM
Last Post: selfieman231
[.NET] by webwarlock72May 30, 2015 03:39 PM 4 119 May 30, 2015 03:39 PM
Last Post: paquiton96