What is the working procedure of ISynchronizeInvoke?
How to work with it in C#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This basically describes a way to push work between threads; to push an item of work onto the other thread, use either
Invoke(synchronous) orBeginInvoke(asynchronous – ideally callingEndInvokelater). Likewise,InvokeRequiredis used to ask “do I need to do this? or can I execute the work myself?”.The most common use of this interface is in windows-forms, where it is part of how to push work onto the UI thread; you can of course use
Control.Invoke/Control.BeginInvokeequally, but forms controls implement this interface to allow abstraction – so downstream code doesn’t need to tie itself to windows forms. In the case of forms,InvokeRequiredmeans “am I the UI thread?”.In reality, I’m not sure it is that common to use it directly. It is more common to handle events on the UI, and have the UI handle thread-switching using the most appropriate local mechanism.
Typical usage:
which executes (via a delegate)
SomeMethodon the thread managed byobj(which implements the interface).