Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

BindingOperations.EnableCollectionSynchronization Method (IEnumerable, Object, CollectionSynchronizationCallback)

.NET Framework 4.6 and 4.5

Enables a collection to be accessed across multiple threads and specifies the callback that should be used to synchronize access to the collection.

Namespace:  System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)

'Declaration
Public Shared Sub EnableCollectionSynchronization ( _
	collection As IEnumerable, _
	context As Object, _
	synchronizationCallback As CollectionSynchronizationCallback _
)

Parameters

collection
Type: System.Collections.IEnumerable

The collection that needs synchronized access.

context
Type: System.Object

An object that is passed to the callback.

synchronizationCallback
Type: System.Windows.Data.CollectionSynchronizationCallback

The callback that is invoked whenever access to the collection is required.

If you have a lot of data to collect or modify, you might want to use a background thread to collect and modify the data so that the user interface will remain reactive to input. To enable multiple threads to access a collection, call the EnableCollectionSynchronization method. This overload of the EnableCollectionSynchronization(IEnumerable, Object, CollectionSynchronizationCallback) method enables you to specify a callback that ensures that the collection is accessed by one thread at a time. You can have the system lock the collection by calling the EnableCollectionSynchronization(IEnumerable, Object) overload. The context parameter is an arbitrary object that you can use to information known when you enable collection synchronization. This is passed to the callback and you can use it to determine the synchronization mechanism to use to control access to collection. Context can be Nothing.

.NET Framework

Supported in: 4.6, 4.5
Show:
© 2015 Microsoft