Google
 

Tuesday, June 05, 2007

What is System.ComponentModel.ISynchronizeInvoke and how to use it?

Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

Remarks

Unlike BeginInvoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.

Use this method when calling a method from a different thread to marshal the call to the proper thread.

MSDN

Remarks

Note:

The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

Sample code:



No comments: