我可以这样做吗using var
:
await foreach (var response in _container.GetItemQueryStreamIterator(query))
{
using var safeResponse = response;
//use the safeResponse
}
或者我应该这样做:
await foreach (var response in _container.GetItemQueryStreamIterator(query))
{
try {
//use response
} finally {
response?.Dispose();
}
}
还是因为迭代器是 anIAsyncDisposable
并且await foreach
会为我做它,所以我可以不进行处理吗?
await foreach (var response in _container.GetItemQueryStreamIterator(query))
{
//use the response
}