BindingBase.EnableCollectionSynchronization Method


Starts synchronization on the collection by using callback and context.

public static void EnableCollectionSynchronization (System.Collections.IEnumerable collection, object context, Xamarin.Forms.CollectionSynchronizationCallback callback);
static member EnableCollectionSynchronization : System.Collections.IEnumerable * obj * Xamarin.Forms.CollectionSynchronizationCallback -> unit



The collection that will be read or updated.


The context or lock object that will be passed to callback. May be null.


The synchronization callback.


Application developers implement callback and pass it to the EnableCollectionSynchronization(IEnumerable, Object, CollectionSynchronizationCallback) method to enable correct multithreaded access to collection. After synchronization is enabled, the Xamarin.Forms framework passes an access method, context, and a bool that indicates whether write access is needed, to the application developer's implementation of CollectionSynchronizationCallback each time that the framework needs to modify the collection in a multithreaded environment. The application developer's implementation should decide, based on the context object (which may be merely a locking object or the object on which the collection lives) and the value of the writeAccessbool parameter, whether or not to lock while calling accessMethod.

Because Xamarin.Forms maintains a weak reference to collection, application developers do not need to call DisableCollectionSynchronization(IEnumerable) to aid in garbage collection.

Applies to