Skip to content

FileStream doesn't agree to be tricked #106917

Discussion options

You must be logged in to vote

Focus on the while loop. Do you see how I first await the readStream.ReadAsync then the writeStream.WriteAsync and thus the total runtime is equal to the combination of reading from the source stream in isolation and writing to the target stream in isolation? I figure out that it is not necessary for these operations to be sequential.

This analysis is overlooking work that the operating system does concurrently with your program. On the receive side, the operating system will receive data over the network and buffer it in the kernel, even if you are not actively calling ReadAsync. On the WriteAsync side, the operating system might complete the write operation without actually writing th…

Replies: 2 comments 15 replies

Comment options

You must be logged in to vote
7 replies
@congthanhnguyenOL
Comment options

@Clockwork-Muse
Comment options

@congthanhnguyenOL
Comment options

@Clockwork-Muse
Comment options

@congthanhnguyenOL
Comment options

Comment options

You must be logged in to vote
8 replies
@AustinWise
Comment options

@congthanhnguyenOL
Comment options

@AustinWise
Comment options

@congthanhnguyenOL
Comment options

@thanh-nguyencong
Comment options

Answer selected by congthanhnguyenOL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants