diff --git a/visual-dotnet/SauceLabs.Visual/VisualBuild.cs b/visual-dotnet/SauceLabs.Visual/VisualBuild.cs index aad5ed2a..eabc43c1 100644 --- a/visual-dotnet/SauceLabs.Visual/VisualBuild.cs +++ b/visual-dotnet/SauceLabs.Visual/VisualBuild.cs @@ -15,7 +15,7 @@ public class VisualBuild public BuildMode Mode { get; internal set; } internal bool IsExternal { get; set; } = false; - internal Func? Closer; + internal Func? Close; internal VisualBuild(string id, string url, BuildMode mode) { diff --git a/visual-dotnet/SauceLabs.Visual/VisualClient.cs b/visual-dotnet/SauceLabs.Visual/VisualClient.cs index fa08bb1f..55216509 100644 --- a/visual-dotnet/SauceLabs.Visual/VisualClient.cs +++ b/visual-dotnet/SauceLabs.Visual/VisualClient.cs @@ -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; } @@ -274,9 +278,9 @@ private async Task VisualCheckAsync(string name, VisualCheckOptions opti /// public static async Task Cleanup() { - if (_sharedBuild?.Closer != null) + if (_sharedBuild?.Close != null) { - await _sharedBuild.Closer(); + await _sharedBuild.Close(); } _sharedBuild = null; }