Load State

A JADE session initiates load state using the JoobConnection BeginLoad method. Load state is terminated when the JoobConnection EndLoad method is called, or when a transaction is terminated (that is, it is committed or rolled back).

When a JADE session is in load state, JADE objects remain locked until load state ends, even if explicitly unlocked using the JoobContext Unlock method.

Using load state avoids the overhead of individually unlocking JADE objects, as objects are unlocked together as a single operation. It also avoids repeatedly locking the same objects, as they remain locked until load state ends.

When EndLoad is called to end load state, only those locks that were acquired while in load state are unlocked. Locks that were in place before load state was activated remain locked.

Load state affects only locks with transaction duration. Session duration locks are not affected.

You can nest BeginLoad calls. A matching EndLoad call unlocks only transaction duration locks acquired at the current nesting level. Load state remains in effect until all BeginLoad calls have been matched with EndLoad calls, or a transaction terminates. Terminating a transaction (for example, by calling Commit or Rollback) ends load state for all nested levels.

Load state can be of use where the same JADE collection is being accessed repeatedly in a code sequence. However, you should keep in mind that while locks are in effect, access by other JADE sessions can be restricted, particularly if the sessions want to update the objects that get locked.

The following code fragment is a contrived example that illustrates load state.

context.Connection.BeginLoad();
C1 c1a = root.AllC1s["a"];
C1 c2b = root.AllC1s["b"];
C1 c2c = root.AllC1s["c"];
context.Connection.EndLoad();

Without load state, the collection root.AllC1s would be implicitly shared-locked and unlocked three times: once for each indexed access. With the use of load state, the collection is locked and unlocked once only, as it remains locked until load state ends.