winforms - Update the GUI from another thread in C# - change back to the main thread or not? -


i know simplest way update label thread is:

void dosomething() {     if (invokerequired)     {         invoke(new methodinvoker(dosomething));     } else      {         //     } } 

my question if instead of if require update gui thread possible change main thread , update gui there ?

actually, simplest way is

invoke(new methodinvoker(dosomething)); 

if call thread sure, ie. if know, invokerequired true.

also, use winforms timer poll changes of, say, text field. timer runs in gui thread. pretty solution if have hundreds of events per second. or @ least "a lot of". way don't have many switches gui thread (which take considerable amount of time).


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -