narkhedegs / Pipe

Pipe streams in .NET without deadlocks.
MIT License
6 stars 1 forks source link

Build status

Pipe

Pipe streams in .NET without deadlocks.




Purpose

Pipe helps to "pipe" the streams in .NET without deadlocks.

Requirements

Installation

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

Usage

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();
}

Credits

All credits goes to madelson. This project is just a small part of MedallionShell published as a separate NuGet package.

License

MIT © narkhedegs