Skip to content

Commit

Permalink
Dispose Close() lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel committed Mar 25, 2024
1 parent 8d9ada5 commit ca2c9a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion visual-dotnet/SauceLabs.Visual/VisualBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class VisualBuild
public BuildMode Mode { get; internal set; }

internal bool IsExternal { get; set; } = false;
internal Func<Task>? Closer;
internal Func<Task>? Close;

internal VisualBuild(string id, string url, BuildMode mode)
{
Expand Down
10 changes: 7 additions & 3 deletions visual-dotnet/SauceLabs.Visual/VisualClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ private async Task SetupBuild(Region region, string username, string accessKey,
Build = _sharedBuild;
var copiedApi = _api.Clone();
var buildId = Build.Id;
_sharedBuild.Closer = async () => await copiedApi.FinishBuild(buildId);
_sharedBuild.Close = async () =>
{
await copiedApi.FinishBuild(buildId);
copiedApi.Dispose();
};
return;
}

Expand Down Expand Up @@ -274,9 +278,9 @@ private async Task<string> VisualCheckAsync(string name, VisualCheckOptions opti
/// </summary>
public static async Task Cleanup()
{
if (_sharedBuild?.Closer != null)
if (_sharedBuild?.Close != null)
{
await _sharedBuild.Closer();
await _sharedBuild.Close();
}
_sharedBuild = null;
}
Expand Down

0 comments on commit ca2c9a1

Please sign in to comment.