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 BriefcaseDb. Here is an example of setting an optimistic policy:


// 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.
briefcaseDb.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

Returns - void

Defined in

Last Updated: 11 June, 2024