EndWrite must be called once for every call to BeginWrite. This can be done either in the same code that called BeginWrite or in a callback that is passed to BeginWrite.
Use the CanWrite property to determine whether the current PipeStream object supports write operations.
If the pipe is closed or an invalid argument is passed to BeginWrite, the appropriate exceptions are raised immediately. Errors that occur during an asynchronous write request occur on the thread pool thread that is performing the request. The exceptions are raised when the code the calls EndWrite method.