c# - Blocking User Process Controller from executing before Control on Winform Fully Loaded and Shown -
i'm creating excel vsto using c#. operation easy, right-click on cell , click on "update" , winform shows progress status prompt out , launch controls on form tied user process controller.
the problem process has launched , executed before form load, there way can block user process controller executing before control on progress status form shown , loaded? image below depict condition.
i have tried put user process controller call in form activated, shown, loaded, , nothing works.
this first stage form loaded. note : 2 line of text has shown user control process has been executed.
i have discovered "hack" overcome issue. add in backgroundworker , done follow code on form constructor.
public summarystatus() { initializecomponent(); backgroundworker = new backgroundworker(); backgroundworker.dowork += backgroundworker_dowork; backgroundworker.runworkercompleted += backgroundworker_runworkercompleted; backgroundworker.runworkerasync(); }
and on dowork event of backgroundworker
void backgroundworker_dowork(object sender, doworkeventargs e) { system.threading.thread.sleep(2000); }
and finally, added following code in run worker completed
void backgroundworker_runworkercompleted(object sender, runworkercompletedeventargs e) { updateupc upc = new updateupc(); upc.txtupdatesummary = txtupdateprogress; upc.updateprogressbar = updateprogressbar; upc.updatestatusonitem(); }
i understand above might not acceptable solution might provide workaround issue. however, if has better solution, feel free drop in suggestion.
Comments
Post a Comment