.net - calculation compile issue with c# timer -


i have windows form label, , system.net timer called atimer.

the timer created in external class this:

// create timer 3 minute interval. common.atimer = new system.timers.timer(3000);  // hook elapsed event timer. common.atimer.elapsed += new elapsedeventhandler(ontimedevent);  // set interval 3 minutes (180000 milliseconds). common.atimer.interval = 180000; // 3000; //   common.atimer.enabled = true; mtimerrunning = true; 

and in form run code ontimedevent kick off background worker

i want show on label number of seconds before next action taken.

i tried won't compile:

lblstatus.begininvoke(new action(() =>                     {         lblstatus.text = "timer running - check inbox in " & common.atimer.interval - common.atimer.elapsed & " seconds!";                     })); 

i have compile error the event 'system.timers.timer.elapsed' can appear on left hand side of += or -=

so correct way this?

ideally every tick of timer update label show when nxt run happen.

i guess you're vb background.

following not valid c# code.

lblstatus.text = "timer running - check inbox in " & common.atimer.interval - common.atimer.elapsed & " seconds!"; 
  • & not used string concatenation in c#, use + operator instead. or better.
  • atimer.interval double, atimer.elapsed event. can't add it. doesn't makes sense.

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -