Skip to content

Commit d718efe

Browse files
authored
Merge pull request #961 from WhitWaldo/updated-actor-csharp-quickstart-language
Clarified actor state persistence description
2 parents 583e9b3 + b6a1a5e commit d718efe

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

actors/csharp/sdk/service/SmokeDetectorActor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected override Task OnActivateAsync()
3636
/// </summary>
3737
protected override Task OnDeactivateAsync()
3838
{
39-
// Provides Opportunity to perform optional cleanup.
39+
// Provides opportunity to perform optional cleanup.
4040
Console.WriteLine($"Deactivating actor id: {Id}");
4141
return Task.CompletedTask;
4242
}
@@ -47,9 +47,12 @@ protected override Task OnDeactivateAsync()
4747
/// <param name="data">the user-defined MyData which will be stored into state store as "device_data" state</param>
4848
public async Task<string> SetDataAsync(SmartDeviceData data)
4949
{
50-
// Data is saved to configured state store *implicitly* after each method execution by Actor's runtime.
51-
// Data can also be saved *explicitly* by calling this.StateManager.SaveStateAsync();
52-
// State to be saved must be DataContract serializable.
50+
// This set state action can happen along other state changing operations in each actor method and those changes will be maintained
51+
// in a local cache to be committed as a single transaction to the backing store when the method has completed. As such, there is
52+
// no need to (and in fact makes your code less transactional) call `this.StateManager.SaveStateAsync()` as it will be automatically
53+
// invoked by the actor runtime following the conclusion of this method as part of the internal `OnPostActorMethodAsyncInternal` method.
54+
55+
// Note also that all saved state must be DataContract serializable.
5356
await StateManager.SetStateAsync<SmartDeviceData>(
5457
deviceDataKey,
5558
data);

0 commit comments

Comments
 (0)