Editar

Compartilhar via


WeakEventManager.ListenerList.PrepareForWriting Method

Definition

Checks to see whether the provided list is in use, and if so, sets the list reference parameter to a copy of that list rather than the original.

public:
 static bool PrepareForWriting(System::Windows::WeakEventManager::ListenerList ^ % list);
public static bool PrepareForWriting (ref System.Windows.WeakEventManager.ListenerList list);
static member PrepareForWriting : ListenerList -> bool
Public Shared Function PrepareForWriting (ByRef list As WeakEventManager.ListenerList) As Boolean

Parameters

list
WeakEventManager.ListenerList

The list to check for use state and potentially copy.

Returns

true if the provided list was in use at the time of call and therefore the list parameter reference was reset to be a copy. false if the provided list was not in use, in which case the list parameter reference remains unaltered.

Remarks

If the given list is in use (which means an event is currently being delivered), calling this method will replace the input list with a clone. The existing users will finish delivering the event to the original list, without interference from changes to the new list.

If the method returns true, callers may want to insert the new list in their own data structures, since this indicates the possibility that the provided list is no longer current.

This method calls BeginUse internally and then immediately calls EndUse. Therefore calling PrepareForWriting does not itself introduce a lock on the list. Even the clone copy is done as a secondary operation after calling EndUse.

Applies to

See also