Ensure proper disposal of resources in InvokeAsync

Updated the `InvokeAsync` method in the `ReC.Client.Api` namespace to use `using` statements for the `content` and `resp` objects. This change ensures proper disposal of these resources, improving memory management and preventing potential leaks. The functional behavior of the method remains unchanged.
This commit is contained in:
2026-05-19 18:44:55 +02:00
parent 82ec333f23
commit 992395dec3

View File

@@ -27,8 +27,11 @@ namespace ReC.Client.Api
public async Task<bool> InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default)
{
var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null;
var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken);
return resp.IsSuccessStatusCode;
using (content)
using (var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken))
{
return resp.IsSuccessStatusCode;
}
}
/// <summary>