Skip to content

Commit aec207d

Browse files
committed
Ensure proper disposal of _nhlPlayerApi resources
Modified the Dispose and DisposeAsync methods in the NhlApi class to include calls to _nhlPlayerApi.Dispose() before GC.SuppressFinalize(this). This ensures that _nhlPlayerApi resources are properly disposed of, preventing potential resource leaks both synchronously and asynchronously.
1 parent 2b506c6 commit aec207d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Nhl.Api/Src/Api/NhlApi.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,21 @@ public async Task<PlayerDraftYear> GetPlayerDraftRankingByYearAsync(string seaso
736736
/// <summary>
737737
/// Releases and disposes all unused or garbage collected resources for the Nhl.Api
738738
/// </summary>
739-
public void Dispose() =>
739+
public void Dispose()
740+
{
741+
_nhlPlayerApi.Dispose();
740742
GC.SuppressFinalize(this);
743+
}
741744

742745
/// <summary>
743746
/// Releases and disposes all unused or garbage collected resources for the Nhl.Api asynchronously
744747
/// </summary>
745748
/// <returns>The await-able result of the asynchronous operation</returns>
746-
public async ValueTask DisposeAsync() =>
747-
await Task.Run(() => GC.SuppressFinalize(this));
749+
public async ValueTask DisposeAsync()
750+
{
751+
_nhlPlayerApi.Dispose();
752+
await Task.Run(() => GC.SuppressFinalize(this));
753+
}
748754

749755
/// <summary>
750756
/// Returns the current NHL playofff schedule for the current season

0 commit comments

Comments
 (0)