setPolicy Method

Set the concurrency control policy. Before changing from optimistic to pessimistic, all local changes must be saved and uploaded to iModelHub. Before changing the locking policy of the pessimistic concurrency policy, all local changes must be saved to the IModelDb. Here is an example of setting an optimistic policy:

Example:

    // Turn on optimistic concurrency control.
    // This allows the app to modify elements, models, etc. without first acquiring locks.
    // Later, when the app downloads and merges changeSets from iModelHub,
    // IModelDb's ConcurrencyControl will merge changes and handle conflicts,
    // as specified by this policy.
    iModel.concurrencyControl.setPolicy(new ConcurrencyControl.OptimisticPolicy());

setPolicy(policy: ConcurrencyControl.PessimisticPolicy | ConcurrencyControl.OptimisticPolicy): void

throws IModelError if the policy cannot be set.

Parameter Type Description
policy ConcurrencyControl.PessimisticPolicy | ConcurrencyControl.OptimisticPolicy The policy to used

Defined in

Last Updated: 13 October, 2019