
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A question of disposability:
It seems like this is a common pattern: (and one I inherited)
public class MyUpdater : IUpdater { private UpdaterId _updaterId; public MyUpdater (AddInId addinInId) { _updaterId = new UpdaterId(addinInId, new Guid(<myUpdaterGuid>)); } }
which leaves an UpdaterId object in the class. Ostensibly for the purposes of supplying an implentation of GetUpdaterId:
public UpdaterId GetUpdaterId() { return _updaterId; }
Noting that UpdaterId is defined in the Revit API thusly:
public class UpdaterId : IDisposable
1. Is there any reason that GetUpdaterId couldn't look like this:
public UpdaterId GetUpdaterId() { return new UpdaterId(addinInId, new Guid(<myUpdaterGuid>)); }
2. If not, shouldn't MyUpdater, in addition to implementing IUpdater, (technically) also implement IDisposable, because UpdaterId implements IDisposable?
and thus we can properly dispose of "_updaterId" when MyUpdater gets garbage collected?
I'm not completely clear on all these concepts beyond that if I implement IDisposable on a class then I need to provide Dispose() but when we've got a member variable which itself implements IDisposable, it gets murky for me. I know this will all get GC'd at the end (when Revit closes) but I'm curious to know more about what's going on here and if there is something I should be doing more correctly.
Thanks for any thoughts.
Solved! Go to Solution.