Skip to content

Commit

Permalink
better Dispose pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
kosak committed Sep 2, 2024
1 parent ceb3967 commit d185285
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions csharp/ExcelAddIn/providers/ClientProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ private void DisposeClientState() {
return;
}

if (_ownedDndClient != null) {
var oldClient = Utility.Exchange(ref _ownedDndClient, null);
if (oldClient != null) {
_observers.SetAndSendStatus(ref _client, "Disposing client");
_ownedDndClient.Dispose();
oldClient.Dispose();
}
}

Expand Down
2 changes: 1 addition & 1 deletion csharp/ExcelAddIn/providers/TableHandleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void DisposePqAndThState() {
return;
}

_ = _tableHandle.GetValueOrStatus(out var oldTh, out var _);
_ = _tableHandle.GetValueOrStatus(out var oldTh, out _);

if (oldTh != null) {
_observers.SetAndSendStatus(ref _tableHandle, "Disposing TableHandle");
Expand Down

0 comments on commit d185285

Please sign in to comment.