ChaosTest.ChaosService.ChaosService.StartAsync C# (CSharp) Méthode

StartAsync() public méthode

Starts the test.
public StartAsync ( ) : Task
Résultat Task
        public async Task StartAsync()
        {
            IReliableDictionary<string, CurrentState> chaosServiceState =
                await this.StateManager.GetOrAddAsync<IReliableDictionary<string, CurrentState>>(StringResource.ChaosServiceStateKey);

            using (ITransaction tx = this.StateManager.CreateTransaction())
            {
                ConditionalValue<CurrentState> currentStateResult =
                    await chaosServiceState.TryGetValueAsync(tx, StringResource.ChaosServiceStateKey, LockMode.Update);

                if (currentStateResult.HasValue &&
                    (currentStateResult.Value == CurrentState.Stopped ||
                     currentStateResult.Value == CurrentState.None))
                {
                    await
                        chaosServiceState.AddOrUpdateAsync(
                            tx,
                            StringResource.ChaosServiceStateKey,
                            CurrentState.Running,
                            (key, existingValue) => CurrentState.Running);
                }

                await tx.CommitAsync();
            }
        }