0

Can I lock a row so that the cursor does not bring it because it is in use by another cursor ?

ITable table=GetTable();
ICursor crntCrsr=null;
ICursor secondCrsr=null;
crntCrsr=table.Search(filter,false);

 // This cursor will contain one row. I want to lock it so that if 
var firstRow= crsntCrsr.NextRow();

// now If I use the same statement as above, I will get the same row again.
// I want to skip this row because it is already being processed by crntCrsr
secondCrsr=table.Search(filter,false);
var secondRow= secondCrsr.NextRow(); 

// basically I do not want secondRow to be the same as firstRow
  • 2
    No, ArcGIS does not support row-level locking. Use a single cursor and assign processing from there. – Vince Mar 25 at 10:07
  • Thanks Vince, I was hoping ArcGIS supports this. My current tool could be used by multiple processes at the same time in different threads. Some processes might come before others, so I need to make sure that 2 processes do not grab the same row, or a row that is already being processed somewhere else. a Select state FOR UPDATE statement will solve this issue. – ZZZ Mar 25 at 10:27
  • 1
    As stated, your threading should be assigned elsewhere. Your current system is likely to cause failure. – Vince Mar 25 at 10:34
  • Instead of var firstRow make it IRow firstRow then you can skip using if (firstRow.OID == secondRow.OID) secondRow= secondCrsr.NextRow(); resources.arcgis.com/en/help/arcobjects-net/componenthelp/… A cursor from an ITable returns IRow objects; I find it best to use the actual object identifier rather than the ambiguous var. – Michael Stimson Mar 28 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.