Pipe streams in .NET without deadlocks.
Pipe helps to "pipe" the streams in .NET without deadlocks.
- .NET 4.5 and above
Pipe is available at Nuget and can be installed as a package using VisualStudio NuGet package manager or via the NuGet command line:
Install-Package Pipe
using Narkhedegs;
var pipe = new Pipe();
// StreamReader could be output of any process. for ex. StandardOutput of System.Diagnostics.Process
var processStream = streamReader.BaseStream;
try
{
int bytesRead;
while(bytesRead = await processStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false)) > 0)
{
await pipe.InputStream.WriteAsync(buffer, 0, bytesRead).ConfigureAwait(false);
}
}
finally
{
processStream.Close();
pipe.InputStream.Close();
}
All credits goes to madelson. This project is just a small part of MedallionShell published as a separate NuGet package.
MIT © narkhedegs