The "Lock()" call is out of the try block

The rule checks for initialization of the data lock. If the creation of a lock is found, the call of the "Lock()" method is checked, and the call must be in a try block.

Noncompliant Code Example

DataLock = new DataLock;
DataLockItem = DataLock.Add("Document.Test");
DataLockItem.Mode = DataLockMode.Exclusive;
DataLock.Lock();

Compliant Solution

BeginTransaction();
Try
    
    DataLock = new DataLock;
    DataLockItem = DataLock.Add("Document.Test");
    DataLockItem.Mode = DataLockMode.Exclusive;
    DataLock.Lock();
    
    CommitTransaction();
   
Except
    RollbackTransaction();

Raise;

EndTry;

See