Redigeeri

Jagamisviis:


EventInfo.RemoveEventHandler(Object, Delegate) Method

Definition

Removes an event handler from an event source.

public:
 virtual void RemoveEventHandler(System::Object ^ target, Delegate ^ handler);
public virtual void RemoveEventHandler (object target, Delegate handler);
public virtual void RemoveEventHandler (object? target, Delegate? handler);
public void RemoveEventHandler (object target, Delegate handler);
abstract member RemoveEventHandler : obj * Delegate -> unit
override this.RemoveEventHandler : obj * Delegate -> unit
Public Overridable Sub RemoveEventHandler (target As Object, handler As Delegate)
Public Sub RemoveEventHandler (target As Object, handler As Delegate)

Parameters

target
Object

The event source.

handler
Delegate

The delegate to be disassociated from the events raised by target.

Implements

Exceptions

The event does not have a public remove accessor.

The handler that was passed in cannot be used.

The target parameter is null and the event is not static.

-or-

The EventInfo is not declared on the target.

Note: In .NET for Windows Store apps or the Portable Class Library, catch Exception instead.

The caller does not have access permission to the member.

Note: In .NET for Windows Store apps or the Portable Class Library, catch the base class exception, MemberAccessException, instead.

Remarks

This method attempts to remove the delegate that may synchronize this event on the target object.

When an event is raised by target, the method or methods encapsulated by handler will no longer be invoked.

Applies to

See also