multithreading - WPF starting up interfaces without freezing the GUI -
i know there bunch of threads initializing stuff in different thread dont need freeze ui. in case initialization involves creating lot of plots (polylines in canvas) seems need freeze ui.
it enough hide frame things being initialized (i let "loading.." message in below) , freeze ui (couple of seconds) , show again frame.
this have far. not working... freezes ui before hiding nothing , unfreezes after loading initializes frame. otherwise thing works charm.
void historics_showexperimentresults(object sender, eventargs e) { aeppage = new aeppage(); resultspage = new aepresultset(); // try hide frame. below there "loading..." nice text. // not sure if it's best way works if dont show @ end paradigmframe.dispatcher.invoke((action)delegate { paradigmframe.content = null; paradigmframe.updatelayout(); }); // initialization needs have gui thread //because draw plots , polylines aeppage.dispatcher.invoke((action)delegate { aeppage.init(resultset); }); //then want go , visualize initialized page plots paradigmframe.dispatcher.invoke((action)delegate { paradigmframe.navigate(aeppage); }); } any clue??? said tried put init in different thread , add event when finished, threads needs control on ui initializing polylines in canvas .. doesn't work :(
thanks in advance !
it looks historics_showexperimentresults running on ui thread. try this:
void historics_showexperimentresults(object sender, eventargs e) { aeppage = new aeppage(); resultspage = new aepresultset(); new thread(_ => { // try hide frame. below there "loading..." nice text. // not sure if it's best way works if dont show @ end paradigmframe.dispatcher.invoke((action)delegate { paradigmframe.content = null; paradigmframe.updatelayout(); }); // initialization needs have gui thread //because draw plots , polylines aeppage.dispatcher.invoke((action)delegate { aeppage.init(resultset); }); //then want go , visualize initialized page plots paradigmframe.dispatcher.invoke((action)delegate { paradigmframe.navigate(aeppage); }); }).start(); }
Comments
Post a Comment