c# - Set Specified date 1 Minute equals 3 months -
datetime newdate = new datetime(2013, 1, 1); private void timer1_tick(object sender, eventargs e) { timer1.tick += new eventhandler(timer1_tick); timer1.interval = 60000; timer1.enabled = true; timer1.start(); newdate.addmonths(+3); lbldate.text = newdate.tostring(); }
using c#, why timer not work? want able set date, (01/01/2013) , each minute proceeds equal 3 months
expanding on @dbaseman 's comment, think part of problem may lie in trying add event listener inside of event listener. try this:
datetime newdate = new datetime(2013, 1, 1); timer1.interval = 60000; timer1.enabled = true; timer1.tick += (object sender, eventargs e) =>{ newdate = newdate.addmonths(+3); lbldate.text = newdate.tostring(); } timer1.start();
or if don't lambdas
void init(){ datetime newdate = new datetime(2013, 1, 1); timer1.interval = 60000; timer1.enabled = true; timer1.tick += new eventhandler(timer1_tick) timer1.start(); } void timer1_tick(object sender, eventargs e) { newdate = newdate.addmonths(+3); lbldate.text = newdate.tostring(); }
Comments
Post a Comment