Skip to content

Commit 863f38c

Browse files
author
Jos Hickson
authored
Added specific warning about pausing the actor.
1 parent 958a9f9 commit 863f38c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

USAGE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ You'd achieve that using the `WhileActorPaused` extension:
161161
```
162162

163163
Essentially this will prevent the actor from doing anything at all until the task returned by `_database.GetEmployee(payrollId)` completes and the first thing processed by the actor when it resumes will be the continuation after the call (i.e. `_cache[payrollId] = ...`).
164+
164165
This device should be used with caution - and would most likely be inappropriate in the case of this example - but could be useful in some circumstances.
166+
Issues can arise with an actor being paused permanently if library code does not use `ConfigureAwait(false)` when awaiting.
167+
For instance, if an implementation of `IEmployeeDatabase.GetEmployee` itself awaited something without using `ConfigureAwait(false)`, then it's likely that the continuation of that await would be scheduled on the actor's work queue.
168+
But, as the actor has been paused, that continuation will never be executed.
169+
Consequently, the continuation of `await _database.GetEmployee(payrollId).WhileActorPaused()` will never be scheduled on the actor and it's the scheduling of this that unpauses the actor.
165170

166171
## Specifying work to do when the actor starts
167172

0 commit comments

Comments
 (0)