Επεξεργασία

Κοινή χρήση μέσω


ISynchronizeInvoke Interface

Definition

Provides a way to synchronously or asynchronously execute a delegate.

public interface class ISynchronizeInvoke
public interface ISynchronizeInvoke
type ISynchronizeInvoke = interface
Public Interface ISynchronizeInvoke
Derived

Remarks

The ISynchronizeInvoke interface provides synchronous and asynchronous communication between objects about the occurrence of an event. Objects that implement this interface can receive notification that an event has occurred, and they can respond to queries about the event. In this way, clients can ensure that one request has been processed before they submit a subsequent request that depends on completion of the first.

The ISynchronizeInvoke class provides two ways to invoke a process:

  1. Asynchronously, by using the BeginInvoke method. BeginInvoke starts a process and then returns immediately. Use EndInvoke to wait until the process started by BeginInvoke completes.

  2. Synchronously, by using the Invoke method. Invoke starts a process, waits until it completes, and then returns. Use Invoke when the control's main thread is different from the calling thread to marshal the call to the proper thread.

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.

Properties

InvokeRequired

Gets a value indicating whether the caller must call Invoke(Delegate, Object[]) when calling an object that implements this interface.

Methods

BeginInvoke(Delegate, Object[])

Asynchronously executes the delegate on the thread that created this object.

EndInvoke(IAsyncResult)

Waits until the process started by calling BeginInvoke(Delegate, Object[]) completes, and then returns the value generated by the process.

Invoke(Delegate, Object[])

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

Applies to

See also