Is there any guidance on how to correctly use objects that implement IDisposable in Orchestration functions?
Let's consider something like this:
using (IActivityScope scope = _activityScopeFactory.CreateScope())
{
await context.CallActivityAsync("TestActivity1");
await context.CallActivityAsync("TestActivity2");
// (...) etc.
}
Unless we're doing something wrong, the current behavior we're observing is that the scope object will be created multiple times, every time the orchestration is re-run to be replayed when the various activity complete. However, the Dispose on said scope only ever gets called once, as the orchestration completes?
Is there a way to somehow get it to always run?
We're doing this for logging and instrumentation, so there's no risk of leaking expensive stuff, but it's still quite annoying because the data we gather with this flow is just not correct. We'd love to get any insight on how to do it the right way.
Is there any guidance on how to correctly use objects that implement
IDisposablein Orchestration functions?Let's consider something like this:
Unless we're doing something wrong, the current behavior we're observing is that the
scopeobject will be created multiple times, every time the orchestration is re-run to be replayed when the various activity complete. However, theDisposeon saidscopeonly ever gets called once, as the orchestration completes?Is there a way to somehow get it to always run?
We're doing this for logging and instrumentation, so there's no risk of leaking expensive stuff, but it's still quite annoying because the data we gather with this flow is just not correct. We'd love to get any insight on how to do it the right way.