Using disposable objects in Orchestration functions
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 6
Description
Is there any guidance on how to correctly use objects that implement `IDisposable` in Orchestration functions?
Let's consider something like this:
```csharp
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.