System.IO.Pipelines.Pipeand have a quick question: How can I know when the
PauseWriterThresholdhas been reached in a
Pipe? I have a thread reading from a UDP port as fast as possible and the thread writes data received into a
Pipebut I don't want the writer to be blocked when
PauseWriterThresholdhas been reached. If the write threshold has been reached, I need to "drop" the write and continue reading UDP port data. I'd like to resume writing data to the
Pipewhen I know I won't be blocked.
Thanks @davidfowl , I'm mostly in a situation where I have a dedicated thread that needs to know a priori if calling a
FlushAsync would ultimately block. In other words, if
Write/FlushAsync.GetAwaiter().GetResult() would block or not. Currently, I don't see anything I can use in the public
Pipe API that I could use to know that the next call with N bytes to
Flush would block.
The only thing I can think of so far, is to keep around the last
Write/FlushAsync and check if
Task.IsCompleted is true or not. Now I have enough information to know if the
Pipe is full or not I guess.