System.ComponentModel.EventHandlerList Class

Assembly: System.dll
Namespace: System.ComponentModel
Summary
Provides a simple list of delegates. This class cannot be inherited.
C# Syntax:
public sealed class EventHandlerList : IDisposable
Remarks
This class uses a linear search algorithm to find entries in the list of delegates. A linear search algorithm is inefficient when working with a large number of entries. Therefore, when you have a large list, finding entries is slow.
Example
For an example on using an EventHandlerList, see the sample in the "Optimizing Event Implementation" section in the conceptual topic at MSDN: definingcustomevent.
See also:
System.ComponentModel Namespace

System.ComponentModel.EventHandlerList Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Public Properties
Item Read-write

Gets or sets the delegate for the specified object.
Public Methods
AddHandler Adds a delegate to the list.
Dispose Disposes the delegate list.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
RemoveHandler Removes a delegate from the list.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.ComponentModel.EventHandlerList Member Details

ctor #1
Summary:
Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public EventHandlerList();

Return to top


Property: Item (read-write)
Summary
Gets or sets the delegate for the specified object.
C# Syntax:
public Delegate this[object key] {get; set;}
Parameters:

key

An object to find in the list.

Remarks
When the key is not found in the list and you provide a delegate to set the value of the key, then the key is added to the top of the list and assigned to the delegate as its value.
See also:
EventHandlerList

Return to top


Method: AddHandler(
   object key,
   Delegate value
)
Summary
Adds a delegate to the list.
C# Syntax:
public void AddHandler(
   object key,
   Delegate value
);
Parameters:

key

The object that owns the event.

value

The delegate to add to the list.

Return to top


Method: Dispose()
Summary
Disposes the delegate list.
C# Syntax:
public void Dispose();
Implements:
IDisposable.Dispose
Remarks
Call EventHandlerList.Dispose when you are finished using the EventHandlerList. The EventHandlerList.Dispose method leaves the EventHandlerList in an unusable state. After calling EventHandlerList.Dispose, you must release all references to the EventHandlerList so the memory it was occupying can be reclaimed by garbage collection.

Note Always call EventHandlerList.Dispose before you release your last reference to the EventHandlerList. Otherwise, the resources the EventHandlerList is using will not be freed until garbage collection calls the EventHandlerList object's destructor.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~EventHandlerList();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: RemoveHandler(
   object key,
   Delegate value
)
Summary
Removes a delegate from the list.
C# Syntax:
public void RemoveHandler(
   object key,
   Delegate value
);
Parameters:

key

The object that owns the event.

value

The delegate to remove from the list.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.