using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Windows; using System.Diagnostics; using System.IO.Pipes; using System.IO; namespace ChildProcess { /// /// Interaction logic for App.xaml /// public partial class App : Application { public static string[] args = {"sdkjfhksdj"}; private void Application_Startup(object sender, StartupEventArgs e) { } private void Application_Exit(object sender, ExitEventArgs e) { if (args.Length > 0) { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.Out, args[0])) { // Show that anonymous Pipes do not support Message mode. try { MessageBox.Show("[CLIENT] Setting ReadMode to \"Message\"."); pipeClient.ReadMode = PipeTransmissionMode.Message; } catch (NotSupportedException ex) { MessageBox.Show("[CLIENT] Execption:\n {0}", ex.Message); } MessageBox.Show("[CLIENT] Current TransmissionMode: {0}.", pipeClient.TransmissionMode.ToString()); using (StreamReader sr = new StreamReader(pipeClient)) { // Display the read text to the console string temp; // Wait for 'sync message' from the server. do { MessageBox.Show("[CLIENT] Wait for sync..."); temp = sr.ReadLine(); } while (!temp.StartsWith("SYNC")); // Read the server data and echo to the console. while ((temp = sr.ReadLine()) != null) { MessageBox.Show("[CLIENT] Echo: " + temp); } } } } MessageBox.Show("[CLIENT] Press Enter to continue..."); Console.ReadLine(); } } }