methods - Running a command once time has been met only once in c# using timer -
i trying invoke message box once time 5pm. once time 5pm , messagebox has showed. want set bool value false whole day. until not next day messagebox shouldn't show. searched on website not finding answer.
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace iqa { public partial class form1 : form { private system.threading.timer timer; public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { this.text = "i[q]a"; timer1.enabled = true; timer1.interval = 1000; timer1.tick +=new eventhandler(timer1_tick); } private void button1_click(object sender, eventargs e) { //messagebox.show("the current time is: " + datetime.now.tostring("h:mm")); } private void timer1_tick(object sender, eventargs e) { if (datetime.now.tostring("h:mm") == "7:57" && ran == false) { messagebox.show("it 7:55"); ran = true; // after message box has shown once still keeps popping up. way stop } else { // nothing } } } }
Comments
Post a Comment