Kirk,It definitely isn't as big of a deal as managing cursors; I've never seen a case where it throws an exception. It can help performance though, and ensures that things behave as expected in some workflows. One that comes to mind is trying to delete local geodatabase after having used a non-recycling cursor. Granted, that's not a common workflow, but it's one that does happen on occasion.If a cursor is recycling, typically I use this kind of pattern:using (ComReleaser comReleaser = new ComReleaser())
{
ICursor cursor = table.Search(null, true);
comReleaser.ManageLifetime(cursor);
IRow row = null;
Boolean isManaged = false;
while ((row = cursor.NextRow()) != null)
{
if (!isManaged)
{
comReleaser.ManageLifetime(row);
isManaged = true;
}
// Use the row...
}
}
Whereas for non-recycling cursors I generally do something like this:using (ComReleaser comReleaser = new ComReleaser())
{
ICursor cursor = table.Search(null, false);
comReleaser.ManageLifetime(cursor);
IRow row = null;
while ((row = cursor.NextRow()) != null)
{
try
{
// Use the row...
}
catch (Exception exc)
{
// Handle the exception...
}
finally
{
Marshal.ReleaseComObject(row);
}
}
}
... with the exception being the odd case where I have to use references to rows other than the last one fetched (like the List<IFeature> scenario you mentioned). In those cases I manage the rows using the ComReleaser.(In the non-recycling case I've also used a nested ComReleaser at times...)Cheers,James