Write
Using system;using system.io;using system.io.pipes;using system.security.principal;using System.Threading;namespace memorywrite{ class program { static void Main (string[] args) { try { Namedpipeclientstream Namedpipeclientstream = new Namedpipeclientstream (".", "Closepipe", Pipedirection.inout, Pipeoptions.none, tokenimpersonationlevel.impersonation); Namedpipeclientstream.connect (); StreamWriter SW = new StreamWriter (namedpipeclientstream); Sw. WriteLine ("Exit"); Sw. Flush (); Thread.Sleep (+); Sw. Close (); } catch (Exception ex) { } } }}
Read
using system;using system.io;using system.io.pipes;using system.threading; Namespace memoryread{class Program {static void Main (string[] args) {while (true) {try {namedpipeserverstream namedpipeserverstream = new Namedpipes Erverstream ("Closepipe", Pipedirection.inout, 2); Namedpipeserverstream.waitforconnection (); StreamReader sr = new StreamReader (namedpipeserverstream); String recdata = Sr. ReadLine (); if (Recdata = = "Exit") {Console.Write ("success"); } thread.sleep (1000); Sr. Close (); } catch (Exception ex) {}}}}
One-way pipelines allow one end to write another, and a bidirectional pipeline allows a process to write data to and from the pipeline.
http://blog.sina.com.cn/s/blog_4b3485000101827p.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C # process synchronization pipeline Communication