/// <summary> /// This method is called whenever an actor is activated. /// An actor is activated the first time any of its methods are invoked. /// </summary> protected override async Task OnActivateAsync() { try { state = await StateManager.GetOrAddStateAsync <PosDeviceSimulationStateType>(StateKey, PosDeviceSimulationStateType.None); stateFlags = await StateManager.GetOrAddStateAsync <PosDeviceSimulationStateType>(StateKey, PosDeviceSimulationStateType.None); ConfigureMachine(); if (_Machine.IsInState(PosDeviceSimulationStateType.None)) { // first load, initalize await this._Machine.FireAsync(PosDeviceSimulationTriggerType.CreateActor); } ActorEventSource.Current.ActorMessage(this, $"Actor [{this.GetActorReference().ActorId.GetGuidId()}] activated."); ActorEventSource.Current.ActorMessage(this, $"Actor [{this.GetActorReference().ActorId.GetGuidId()}] state at activation: {this.state}"); } catch (Exception ex) { WriteTimedDebug(ex); throw; } }
private async Task OnCreated() { if (!this.stateFlags.HasFlag(PosDeviceSimulationStateType.ActorCreated)) { // Only way to clean up the Actor Instance so do it first //await RegisterKillMeReminder(); this.stateFlags = this.stateFlags | PosDeviceSimulationStateType.ActorCreated; await SetStateAsync(); await StateManager.SaveStateAsync(); } }