Updating ui from another thread c terry ronzio dating

Access to Windows Forms controls is not inherently thread safe.If you have two or more threads manipulating the state of a control, it is possible to force the control into an inconsistent state.For this reason, it is recommended to keep message processing short and simple.Long running operations performed on this thread will cause incoming Windows messages to queue up.If messages don't get processed in a timely manner, the application will appear hung to the user and provide a poor user experience.

This is because UI elements can only be updated from the threads that created them.Other thread-related bugs are possible, such as race conditions and deadlocks.It is important to make sure that access to your controls is performed in a thread-safe way.In order to use this, one must declare a function that performs the UI operation.For example, say a form has a Text Box on it named Note: Do not create a method that matches the Event Handler delegate signature and pass that.

Leave a Reply