internal static async Task SetPropertyAndWriteStateAsync <TGrainState>(Action <TGrainState> setterAction, IIndexedState <TGrainState> indexedState, bool retry)
            where TGrainState : class, new()
        {
            const int MaxRetries = 10;
            int       retries    = 0;

            while (true)
            {
                try
                {
                    await indexedState.PerformUpdate(setterAction);

                    return;
                }
                catch (Exception) when(retry && retries < MaxRetries)
                {
                    ++retries;
                    await indexedState.PerformRead();
                }
            }
        }
 public static Task PerformUpdate <TGrainState>(this IIndexedState <TGrainState> indexedState, Action <TGrainState> updateAction)
     where TGrainState : class, new()
 => indexedState.PerformUpdate(state => { updateAction(state); return(true); });