Hi
Its mentioned in the critical section rules that "Critical sections can signal only entities they haven't locked." but in the example given, the below lines would fail to execute inside the lock.
await sourceProxy.Add(-transferAmount);
await destinationProxy.Add(transferAmount);
using (await context.LockAsync(sourceEntity, destinationEntity))
{
ICounter sourceProxy =
context.CreateEntityProxy<ICounter>(sourceEntity);
ICounter destinationProxy =
context.CreateEntityProxy<ICounter>(destinationEntity);
int sourceBalance = await sourceProxy.Get();
if (sourceBalance >= transferAmount)
{
await sourceProxy.Add(-transferAmount);
await destinationProxy.Add(transferAmount);
// the transfer succeeded
return true;
}
else
{
// the transfer failed due to insufficient funds
return false;
}
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 87e12177-bb3a-d00c-99a5-422e00f9b03f
Version Independent ID: 2fa1cf0d-2a5f-2fb0-ef25-bccfac3279fd
Hi Its mentioned in the critical section rules that "Critical sections can signal only entities they haven't locked." but in the example given, the below lines would fail to execute inside the lock. await sourceProxy.Add(-transferAmount); await destinationProxy.Add(transferAmount);
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.