Monday 15 September 2014

c# - Message Box Pops up more than once -



c# - Message Box Pops up more than once -

i have next code, timerstart method phone call functions every second, problem when status true in checksigning method, pop appears more once.. how can perchance prepare this? can help me :<

public void timerstart() { dispatchertimer updatertimer = new dispatchertimer(); updatertimer.tick += new eventhandler(updatertimer_tick); updatertimer.interval = new timespan(0, 0, 1); updatertimer.start(); } private void updatertimer_tick(object sender, eventargs e) { time.content = "time : " + datetime.now.tolongtimestring(); exist = saved_settings(); if (exist) { settingfortoday(); checksigningavailable(); setsigning(signingavailable = getsigning()); } else { ongoing.content = "event : no event"; sign_in.content = "sign-in time : "; sign_out.content = "sign-out time : "; } } public void checksigningavailable() { if (dt_signing_in.compareto(datetime.now) < 0) { if ((!inisover && signing.equals("in")) || (!inisover && signing.equals("in_out") && !outisover)) { disablesigningin(outisover.tostring(),this.event_id); } } if (dt_signing_out.compareto(datetime.now) < 0) { if ((!outisover && signing.equals("out")) || (!outisover && signing.equals("in_out") && inisover)) { disablesigningout(inisover.tostring(),this.event_id); } } } public void disablesigningout(string in,string event_id) { messagebox.show("signing out over!", "no more signing out!", messageboxbutton.ok, messageboximage.information); connection.open(); string sign = in + ",true"; string query = "update data_storage set data_details = '" + sign + "' data_name = 'signing';"; npgsqlcommand command = new npgsqlcommand(query, connection); npgsqldatareader dr = command.executereader(); dr.close(); connection.close(); sign_out.content = "sign-out time : over"; string query2 = concatquery(getidnumberattendance(event_id)); updateabsences(query2); }

you can stop timer while execute tick , start 1 time again on end. downwards side have time measure form moment finish updatertimer_tick execution - may consider benefit.

private void updatertimer_tick(object sender, eventargs e) { updatertimer.stop(); time.content = "time : " + datetime.now.tolongtimestring(); exist = saved_settings(); if (exist) { settingfortoday(); checksigningavailable(); setsigning(signingavailable = getsigning()); } else { ongoing.content = "event : no event"; sign_in.content = "sign-in time : "; sign_out.content = "sign-out time : "; } updatertimer.start(); }

c# wpf postgresql timer messagebox

No comments:

Post a Comment