c# - Timer starts only after the Form is closed -


i working on c# application runs on windows ce 5 device ms compact framework 2.0. in application call singleton dialog keyboard-hook asynchronously via begininvoke:

this.begininvoke((threadstart)delegate() {     dlgx.getinstance().display(taskcontroller.getinstance().getactivetask().getvalues(), true); }); 

in display method of dialog want set focus control. win ce device slow, have use timer delay focus() execution:

system.windows.forms.timer timer = new system.windows.forms.timer(); timer.interval = 600; timer.enabled = true; timer.tick += (eventhandler)delegate(object obj, eventargs args) {     button1.focus();     timer.dispose(); }; 

unfortunately not work. timer gets executed close dialog. doing wrong?

thank in advance help!

edit: whole display() method of dialog:

public void display(list<inputrow> fvlist, bool validate) {     this.fvlist = fvlist;     ctlcount = (fvlist.count > 5 ? 5 : fvlist.count);     (int = 0; < ctlcount; i++)     {          //some 100% irrelevant stuff     }     button1.keydown += new keyeventhandler(btnok_keydown);     button1.click += new eventhandler(btnok_click);     if (!this.visible)     {         showdialog();     }     if (validate)     {         system.windows.forms.timer timer = new system.windows.forms.timer();         timer.interval = 600;         timer.enabled = true;         timer.tick += (eventhandler)delegate(object obj, eventargs args)         {             button1.focus();             timer.dispose();         };     } } 

the timer instantiation , enabling evaluated when close form, because showdialog synchronous. should put timer before showdialog


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -