Confusion about PipeReader
#81819
-
According to https://learn.microsoft.com/en-us/dotnet/standard/io/pipelines#pipereader:
If I want to reference a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Not sure if you have gotten your answer elsewhere, but if you want to keep the data after you call The alternative of course is to delay the call to |
Beta Was this translation helpful? Give feedback.
Not sure if you have gotten your answer elsewhere, but if you want to keep the data after you call
AdvanceTo
you will need to copy it. If you useTryGetReadOnlyMemory
it will give you a reference to the underlying memory that the Pipe owns. AfterAdvanceTo
is called then the Pipe may reuse or clobber that memory.The alternative of course is to delay the call to
AdvanceTo
until you are done with the memory, but that might not be possible as you are hinting.