<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;net5.0</TargetFrameworks>
</PropertyGroup>
</Project>
Может какие-то конкретные книги можете посоветовать?
The lifetime of a local variable is the portion of program execution during which storage is guaranteed to be reserved for it. This lifetime extends at least from entry into the block, for_statement, switch_statement, using_statement, foreach_statement, or specific_catch_clause with which it is associated, until execution of that block, for_statement, switch_statement, using_statement, foreach_statement, or specific_catch_clause ends in any way. (Entering an enclosed block or calling a method suspends, but does not end, execution of the current block, for_statement, switch_statement, using_statement, foreach_statement, or specific_catch_clause.) If the local variable is captured by an anonymous function (Captured outer variables), its lifetime extends at least until the delegate or expression tree created from the anonymous function, along with any other objects that come to reference the captured variable, are eligible for garbage collection.
private static Array Combine(params object[] arrays)
{
if (arrays.Length == 0) return null;
if (arrays.Length == 1) return (Array)arrays[0];
var totalLength = ((Array)arrays[0]).Length;
var elemType = arrays[0].GetType().GetElementType();
for (int i = 1; i < arrays.Length; i++)
{
var nextElemType = arrays[i].GetType().GetElementType();
if (nextElemType != elemType) return null;
totalLength += ((Array)arrays[i]).Length;
}
Array resultArray = Array.CreateInstance(elemType, totalLength);
var offset = 0;
foreach (Array array in arrays)
{
Array.Copy(array, 0, resultArray, offset, array.Length);
offset += array.Length;
}
return resultArray;
}
ns.Read(headerBuffer); // прочитали заголовок
watch.Start();
var responseTask = app.Client.GetAsync("test/GetTestMethod");
watch.Stop();
var requestTime = watch.ElapsedMilliseconds;
watch.Restart();
watch.Start();
var response = await responseTask;
watch.Stop();
var fromRequestToStartResponse = watch.ElapsedMilliseconds;
watch.Restart();
watch.Start();
var content = await response.Content.ReadAsStringAsync();
watch.Stop();
var fromStartResponseToEndResponse = watch.ElapsedMilliseconds;
ToArrayAsync выполняет запрос асинхронно и не блокирует поток
AsEnumerable вроде тоже выполняется не сразу (будут ли блокировки при использовании)