Click here to Skip to main content
12,072,749 members (67,223 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.8K views
4 bookmarked
Posted

Changing a WinForms Control on the 'UI' Thread from another Thread

, 23 Mar 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
this.BeginInvo...
this.BeginInvoke((ThreadStart)delegate()                        {                           
 
//UI change code goes here 
                                  
});

[Added by DaveyM69] This method is similar to my suggestion. The ThreadStart delegate is identical to MethodInvoker (void return - no parameters). In this situation I prefer MethodInvoker as that's what we're doing (invoking a method), not starting a thread.

The use of BeginInvoke will may* allow the calling thread to continue immediately even if the 'UI thread' cannot be updated whereas Invoke will block until the 'UI thread' is updated. This may or may not be desirable!

*See Luc's post in the forum below

See:
Control.Invoke[^]
Control.BeginInvoke[^] [/Added]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Khaniya
Software Developer
India India
Life is Mirror !!!!!!!

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160208.1 | Last Updated 23 Mar 2010
Article Copyright 2010 by Khaniya
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid