Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docs/compare-exchange/content/_delete-cmpxchg-items-csharp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ import CodeBlock from '@theme/CodeBlock';
long indexOfItem = resultOfDelete.Index; // The version of the deleted item

// If 'successful' is true - the compare-exchange item was deleted.
// If 'successful' is false - the item was not deleted (index mismatch).

// If 'successful' is false -
// * The item was not deleted because the index didn't match (it was modified by someone else).
// In this case, 'resultOfDelete.Value' will contain the current value stored on the server.
// * Or the item no longer existed at the time of deletion (it was already deleted).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider that the same as "the index didn't match," since the index of a non-existent entry is 0.
But it's not important, it's good to be explicit about it, like you did.
You can consider adding here that distinguishing between a case where the compare-exchange exists with a different index and a case where the compare-exchange does not exist can be determined by the returned object.
If the compare-exchange does not exist, this will be null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

// In this case, 'resultOfDelete.Value' will be null.
}
```
</TabItem>
Expand All @@ -281,14 +286,20 @@ import CodeBlock from '@theme/CodeBlock';
itemToDelete.Key, itemToDelete.Index);

// Execute the delete operation by passing it to Operations.SendAsync
CompareExchangeResult<string> resultOfDelete = await store.Operations.SendAsync(deleteCmpXchgOp);
CompareExchangeResult<string> resultOfDelete = await
store.Operations.SendAsync(deleteCmpXchgOp);

// Check results
bool successful = resultOfDelete.Successful; // Has operation succeeded
long indexOfItem = resultOfDelete.Index; // The version of the deleted item

// If 'successful' is true - the compare-exchange item was deleted.
// If 'successful' is false - the item was not deleted (index mismatch).

// If 'successful' is false -
// * The item was not deleted because the index didn't match (it was modified by someone else).
// In this case, 'resultOfDelete.Value' will contain the current value stored on the server.
// * Or the item no longer existed at the time of deletion (it was already deleted).
// In this case, 'resultOfDelete.Value' will be null.
}
```
</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ import CodeBlock from '@theme/CodeBlock';
const indexOfItem = resultOfDelete.index; // The version of the deleted item

// If 'successful' is true - the compare-exchange item was deleted.
// If 'successful' is false - the item was not deleted (index mismatch).

// If 'successful' is false -
// * The item was not deleted because the index didn't match (it was modified by someone else).
// In this case, 'resultOfDelete.value' will contain the current value stored on the server.
// * Or the item no longer existed at the time of deletion (it was already deleted).
// In this case, 'resultOfDelete.value' will be null.
}
```
</TabItem>
Expand Down
Loading