Actor Timers - Registering timer arguments - Why Func <object, task> and not Func <Task>

Signature for registering a timer in an actor:

IActorTimer RegisterTimer(Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period);

Question:

Why asynCallback expects to receive state as an argument to a function of an object of type. In the end, my callback is already part of the Actor and can directly contact the state. Therefore, the requirement for an object as a parameter seems redundant.

Current thoughts

A possible reason is that this allows us to give subjects a callback status that is not part of the actor (this is even possible). This is the only reason? Or do I have additional considerations when handling state using a timer activated method?

+4
1

( ActorTimers), , ( ), , .

: https://github.com/Azure-Samples/service-fabric-dotnet-iot/blob/master/src/actors/StorageActor/StorageActor.cs

"false" "" . SaveToStorage , ( OnDeactivateAsync), .SaveToStorage true.

+5

All Articles