WeakEventManager.ListenerList.BeginUse Method


Declares the list to be in use. This prevents direct changes to the list during iterations of the list items.

 bool BeginUse();
public bool BeginUse ();
member this.BeginUse : unit -> bool
Public Function BeginUse () As Boolean



true if the list was already declared to be in use; otherwise, false.


A WeakEventManager implementation should call BeginUse before iterating through the list to deliver an event to the listeners, and should call EndUse when it is done. This prevents another caller from modifying the list while the iteration for purposes of event delivery is in progress. If the list is modified during this time, then the list is cloned. If the list is cloned, then PrepareForWriting returns true, which means that you have missed a recent listener change in the last delivery.

Applies to

See also