public async Task <ModuleInfo> GetModuleInfo(CancellationToken cancellationToken) { ActorEventSource.Current.ActorMessage(this, "GetModuleInfo called"); var info = await this.StateManager.TryGetStateAsync <ModuleInfo>(MODULEINFOSTATENAME, cancellationToken); return(info.HasValue ? info.Value : ModuleInfo.DefaultModuleInfo(GetSubId())); }
/// <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 Task OnActivateAsync() { ActorEventSource.Current.ActorMessage(this, "Actor activated."); // The StateManager is this actor's private state store. // Data stored in the StateManager will be replicated for high-availability for actors that use volatile or persisted state storage. // Any serializable object can be saved in the StateManager. // For more information, see https://aka.ms/servicefabricactorsstateserialization return(this.StateManager.TryAddStateAsync(MODULEINFOSTATENAME, ModuleInfo.DefaultModuleInfo(GetSubId()))); }