简体   繁体   中英

Java's PipedReader / PipedWriter equivalents in C#?

I have defined a Pipe class in Java, making use of PipedReader and PipedWriter . I am now trying to port this same class to C#. Is it possible to accomplish the same as shown in the following code in C#?

public final class Pipe {
    private final PipedReader pipedReader = new PipedReader();
    private final PipedWriter pipedWriter = new PipedWriter();

    public Pipe() {
        pipedWriter.connect(pipedReader);
    }

        ...
}

I am guessing what I'll want to use in C# for PipedReader and PipedWriter will be StreamReader and StreamWriter ?

Is there something like a connect() method?

Edit

So, my goal is to implement a (little) Pipe&Filter framework. My idea would be to create a Pipe class and Filter classes, so that when I need to implement some system using a Pipe&Filter architecture style, I'll code it against this little framework I am using. Each filter would run on its own thread.

Thanks

I'm not sure if this is exactly what you are looking for, but there is a tutorial on using .Net pipes here . This will only work with .Net 3.5+.

EDIT:

There are examples on MSDN about using anonymous pipes. See this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM