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