Home > OS >  Several invokes to GUI from one thread
Several invokes to GUI from one thread

Time:03-06

If I run several Invokes from a thread, does it run one after each other?

For example, I have a ListView control and after getting the actual information from a server, I need to clear the items, update group names, add new items, etc. All this requires many call to GUI. Is it sure it will be executed in the called sequence?

CodePudding user response:

Both Control.Invoke and Control.BeginInvoke guarantee the execution order if called from the same thread.

Control.Invoke is synchrnous, so you will not able to call next Invoke before the current one will finish.

Control.BeginInvoke uses windows messages under the hood and windows messages are prcessed in order in the message loop, so this also will be executed in the same order as it was called.

  • Related