You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second parameter of context.CreateTimer, that should be the state, not the cancellationToken, am I right? I'm trying to understand how to use this in my own projects, and looking at the source code to understand.
In this particular scenario, the state returned from the CreateTimer is not used, so it might not be easy to spot, but shouldn't the line be:
object dummyState = new object() // whatever, the result is not used in this example
Task timeoutTask = context.CreateTimer(deadline, dummyState, cts.Token);
where dummyState is the state? If not, the timer will never be cancelled, even when the approval task completes, and the orchestration instance will never finish?
Or have I misunderstood how this works?
The text was updated successfully, but these errors were encountered:
I think you're right. In fact, passing a cancellation token as the state parameter can be quite dangerous since deserializing cancellation tokens can result in memory corruption. We'll look into fixing this test code and maybe adding a runtime check for this mistake. Thanks for bringing this up.
Nice, thanks a lot for your input! It aligns with what I see in my own code too. The timer never gets cancelled, even if I cancel the CancellationTokenSource, if I use it as in the example. However, if I pass a(ny) state as the 2nd parameter, and the cancellation token as the last parameter, things work as expected
Referring to
https://github.com/Azure/durabletask/blob/main/test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs#L3151, which is:
The second parameter of
context.CreateTimer
, that should be thestate
, not the cancellationToken, am I right? I'm trying to understand how to use this in my own projects, and looking at the source code to understand.In this particular scenario, the state returned from the CreateTimer is not used, so it might not be easy to spot, but shouldn't the line be:
where
dummyState
is the state? If not, the timer will never be cancelled, even when the approval task completes, and the orchestration instance will never finish?Or have I misunderstood how this works?
The text was updated successfully, but these errors were encountered: