Skip to content

Question: cancellation token in durable entity (isolated) #2740

Answered by jviau
gha-zund asked this question in Q&A
Discussion options

You must be logged in to vote

You can manually construct your entity and then dispatch to it. https://github.com/Azure/azure-functions-durable-extension/blob/dev/src/Worker.Extensions.DurableTask/TaskEntityDispatcher.cs#L36

TaskEntityDispatcher dispatcher = ...;
MyEntity myEntity = new(FunctionContext.CancellationToken); // If needing DI, can use FunctionContext.InstanceServices and ActivatorUtils, which lets you combine DI and manual parameters.
return dispatcher.DispatchAsync(myEntity);

For DI'ing FunctionsContext directly in, you can also follow this: https://gist.github.com/dolphinspired/796d26ebe1237b78ee04a3bff0620ea0

Replies: 5 comments 14 replies

Comment options

You must be logged in to vote
8 replies
@gha-zund
Comment options

@gha-zund
Comment options

@cgillum
Comment options

@jviau
Comment options

jviau Feb 9, 2024
Maintainer

Answer selected by gha-zund
@gha-zund
Comment options

@gha-zund
Comment options

@gha-zund
Comment options

@gha-zund
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jviau
Comment options

jviau Feb 9, 2024
Maintainer

@gha-zund
Comment options

Comment options

You must be logged in to vote
4 replies
@cgillum
Comment options

@jviau
Comment options

jviau Feb 9, 2024
Maintainer

@gha-zund
Comment options

@gha-zund
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants