C# WPF GUI performance MVVM -


i'm looking way improve performances of code. i've got wpf gui textbox , graph (from oxyplot package). used stopwatch find place code less efficient , found takes more time update text of textbox fill string. example, if property mytext bound text property of textbox part of code

application.current.dispatcher.invoke(()=>{    mytext = currentstring; }); 

takes more time of this

stringbuilder sb = new stringbuilder(); retrievedatafromdevice(); fillstring(sb); string currentstring = sb.tostring(); 

and stopwatch :

task.factory.startnew(() => {    var sw = new stopwatch();    sw.start();    stringbuilder sb = new stringbuilder();    retrievedatafromdevice();    fillstring(sb);    string currentstring = sb.tostring();    trace.writeline(sw.elapsedmilliseconds.tostring()); //5ms    sw.restart();    application.current.dispatcher.invoke(()=>{       mytext = currentstring;    });    trace.writeline(sw.elapsedmilliseconds.tostring()); //10ms } 

there performance issue can not refresh string (or graph) more every 15ms. there way improve these performances ?

try use dispatcher.begininvoke method instead of invoke method.

this method not wait ui thread process request before being able continue. puts request in ui thread's queue , returns immediately.

this allow more processing in background thread while ui thread processing ui requests.

having said that, there should reasonable amount of ui update requests ask ui thread process per second.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -