private void btnSet_Click(object sender, EventArgs e) { timer1.Enabled = true; timer1.Start(); timer1.Interval = 5000; } private void timer1_Tick(object sender, EventArgs e) { label1.Text = "Hello"; }
Timer
timer.Start(); void timer_click() { // some code }
myFunction(); timer.Start(); void timer_click() { myFunction(); } void myFunction() { // some code }
private void btnSet_Click(object sender, EventArgs e) { timer1.Enabled = true; timer1.Interval = 5000; timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { label1.Text = "Hello"; }
private void btnSet_Click(object sender, EventArgs e) { var t = new Timer(); t.Interval = 5000; t.Tick += (s, e) => { label1.Text = "Hello"; t.Stop(); }; t.Start(); }
s, e
Object sender, EventArgs e
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)