0

I have this code in my Azure Function:

using var entityLock = await orchestrationContext.LockAsync(entityId);

for (int i = 0; i < 3; i++)
{
    // call an entity function, if it does not succeed : wait with a timer like this and then try again
    await orchestrationContext.CreateTimer(oneHourInTheFuture, CancellationToken.None);
}

I would like to understand if the lock will be held for the whole duration of the orchestration including the timer or the lock will be released when the orchestration is waiting.

Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207

1 Answers1

1

Since the CreateTimer is still in the using statement, the lock will not be released. The lock will be held for the whole duration of the orchestration including the timer in your case.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60