Skip to content

Commit

Permalink
[MTGOSDK/API] Client: Handle disposal when clearing client cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Qonfused committed May 28, 2024
1 parent 0a0bce4 commit 80d1b17
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions MTGOSDK/src/API/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,11 @@ public Client(
/// <summary>
/// Cleans up any cached remote objects pinning objects in client memory.
/// </summary>
public void ClearCaches()
/// <param name="disconnect">Whether to disconnect the client.</param>
public void ClearCaches(bool disconnect = false)
{
if (disconnect) RemoteClient.Dispose();

Log.Debug("Disposing all pinned remote objects registered with the client.");
UserManager.Users.Clear();
CollectionManager.Cards.Clear();
Expand All @@ -232,8 +235,7 @@ public void ClearCaches()
/// </summary>
public void Dispose()
{
ClearCaches();
RemoteClient.Dispose();
ClearCaches(disconnect: true);
}

//
Expand Down

0 comments on commit 80d1b17

Please sign in to comment.