Please explain what will give the IsAsync = true
property in FileStream
. Documentation.
This variant uses this property
await using FileStream fileStream = new(path, FileMode.Create, FileAccess.Write,
FileShare.Read, 4096, true);
await using MemoryStream memoryStream = new(bytes);
await memoryStream.CopyToAsync(fileStream, cancellationToken);
In this version without it
await using FileStream fileStream = new(path, FileMode.Create, FileAccess.Write);
await using MemoryStream memoryStream = new(bytes);
await memoryStream.CopyToAsync(fileStream, cancellationToken);
How will the behavior change? It is not clear to me why I should use it at all if I make a memoryStream.CopyToAsync
.
This property allows you to open a file in some special asynchronous thread, does it belong to some other thread pool?
If we are talking about the Web API, does this property give me an advantage similar to the usual asynchronous calls in which the main thread is released?