public void ForNonSeekable(string input, params string[] lines) { using (var s = new AnonymousPipeServerStream()) using (var c = new AnonymousPipeClientStream(s.GetClientHandleAsString())) { var bytes = Encoding.ASCII.GetBytes(input); s.Write(bytes, 0, bytes.Length); s.Close(); var skipLF = false; foreach (var line in lines) { Assert.Equal(line, c.ReadProtocolLineWithEnd(skipLF)); skipLF = (line.Last() == '\r'); } } using (var s = new AnonymousPipeServerStream()) using (var c = new AnonymousPipeClientStream(s.GetClientHandleAsString())) { var bytes = Encoding.ASCII.GetBytes(input); s.Write(bytes, 0, bytes.Length); s.Close(); var skipLF = false; foreach (var line in lines) { Assert.Equal(line.TrimEnd(LineEnds), c.ReadProtocolLine(skipLF)); skipLF = (line.Last() == '\r'); } } }
/// <summary> /// 方法 匿名パイプを使用してローカル プロセス間の通信を行う /// http://msdn.microsoft.com/ja-jp/library/bb546102.aspx /// の親プロセス側実装(入出力に対応させた) /// ・AnonymousPipeServerStream クラス (System.IO.Pipes) /// http://msdn.microsoft.com/ja-jp/library/system.io.pipes.anonymouspipeserverstream.aspx /// ・AnonymousPipeClientStream クラス (System.IO.Pipes) /// http://msdn.microsoft.com/ja-jp/library/system.io.pipes.anonymouspipeclientstream.aspx /// </summary> public static void Main(string[] args) { if (args.Length > 0) { using (PipeStream pipeClientIn = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { using (PipeStream pipeClientOut = new AnonymousPipeClientStream(PipeDirection.Out, args[1])) { // 匿名パイプでは、Message送信モードはサポートされません。 // http://msdn.microsoft.com/ja-jp/library/system.io.pipes.pipetransmissionmode.aspx // 匿名パイプの送信モードを取得:Byteになっている筈(デバッグ) Debug.WriteLine(string.Format( "[Child] pipeClientIn.TransmissionMode: {0}.", pipeClientIn.TransmissionMode.ToString())); Debug.WriteLine(string.Format( "[Child] pipeClientOut.TransmissionMode: {0}.", pipeClientOut.TransmissionMode.ToString())); using (StreamReader sr = new StreamReader(pipeClientIn)) { using (StreamWriter sw = new StreamWriter(pipeClientOut)) { string temp; sw.AutoFlush = true; while ((temp = sr.ReadLine()) != null) { Debug.WriteLine("[Child] Debug: " + temp); // 前・子プロセスへの書き込みが // 全て読み取られるまで待つ。 pipeClientOut.WaitForPipeDrain(); if (temp.ToUpper().IndexOf("EXIT") != -1) { // 終了する場合 Debug.WriteLine("[Child] Debug EXIT"); sw.WriteLine("[Child] EXIT"); sw.Flush(); break; } else { // 継続する場合 // 入力を反転して出力する。 Debug.WriteLine("[Child] Debug Reversal: " + Program.Reverse(temp)); sw.WriteLine("[Child] Reversal: " + Program.Reverse(temp)); sw.Flush(); } } } } } } } }
public void StartClient(string pipeNameInput, string pipeNameOutput) { _inClient = new AnonymousPipeClientStream(PipeDirection.In, pipeNameInput); _outClient = new AnonymousPipeClientStream(PipeDirection.Out, pipeNameOutput); _readStream = new StreamString(_inClient); _writeStream = new StreamString(_outClient); }
// ReSharper disable UseObjectOrCollectionInitializer private ConsoleRedirector(ILogListener logListener) { bool ret; AnonymousPipeClientStream client; _logListener = logListener; _stdout = GetStdHandle(STD_OUTPUT_HANDLE); _stderr = GetStdHandle(STD_ERROR_HANDLE); _sync = new Mutex(); _buffer = new char[BUFFER_SIZE]; _outServer = new AnonymousPipeServerStream(PipeDirection.Out); client = new AnonymousPipeClientStream(PipeDirection.In, _outServer.ClientSafePipeHandle); //client.ReadTimeout = 0; Debug.Assert(_outServer.IsConnected); _outClient = new StreamReader(client, Encoding.Default); ret = SetStdHandle(STD_OUTPUT_HANDLE, _outServer.SafePipeHandle.DangerousGetHandle()); Debug.Assert(ret); _errServer = new AnonymousPipeServerStream(PipeDirection.Out); client = new AnonymousPipeClientStream(PipeDirection.In, _errServer.ClientSafePipeHandle); //client.ReadTimeout = 0; Debug.Assert(_errServer.IsConnected); _errClient = new StreamReader(client, Encoding.Default); ret = SetStdHandle(STD_ERROR_HANDLE, _errServer.SafePipeHandle.DangerousGetHandle()); Debug.Assert(ret); Thread outThread = new Thread(doRead); Thread errThread = new Thread(doRead); outThread.Name = "stdout logger"; errThread.Name = "stderr logger"; outThread.Start(_outClient); errThread.Start(_errClient); _timer = new Timer(flush, null, PERIOD, PERIOD); }
/// <summary> /// Der Einsprungpunkt für einen <i>Card Server</i>. Die Befehlszeilenparameter beschreiben /// die Kommunikationskanäle zum steuernden Client. /// </summary> /// <param name="args">Befehlsparameter für die Kommunikation.</param> public static void Main( string[] args ) { // Be safe try { // Always use the configured language UserProfile.ApplyLanguage(); // Set priority Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Open the communication channels and attach to the pipe server using (AnonymousPipeClientStream reader = new AnonymousPipeClientStream( PipeDirection.In, args[0] )) using (AnonymousPipeClientStream writer = new AnonymousPipeClientStream( PipeDirection.Out, args[1] )) using (ServerImplementation server = ServerImplementation.CreateInMemory()) for (Request request; null != (request = Request.ReceiveRequest( reader )); ) { // Process it Response response = request.Execute( server ); // Send the response response.SendResponse( writer ); } } catch (Exception e) { // Report error Logging.Log( EventLogEntryType.Error, e.ToString() ); } }
public DuplexAnonymousPipeClient(AnonymousPipeClientStream sender, AnonymousPipeClientStream receiver, ChannelSettings? settings = null) { if (sender == null) throw new ArgumentNullException(nameof(sender)); if (receiver == null) throw new ArgumentNullException(nameof(receiver)); channel = new DuplexPipeChannel(sender, receiver, settings); }
/// <summary> /// Starts the Kinect and waits for an end of stream. /// </summary> public override void Start() { try { #if (DEBUG) Console.WriteLine("[Client] Starting pipe stream"); #endif clientStream = new AnonymousPipeClientStream(PipeDirection.Out, serverHandle); #if (DEBUG) Console.WriteLine("[Client] Stream opened"); #endif sensor = null; //#if (DEBUG) // Console.WriteLine("[Client] Found {0} Kinects", KinectSensor.KinectSensors.Count); //#endif // Start the Kinect initKinect(); // Wait until the connection is severed while (clientStream.IsConnected); } catch (Exception e) { #if (DEBUG) Console.WriteLine("[Client] Exception:\n {0}\nTrace: {1}", e.Message, e.StackTrace); #else throw e; #endif } }
static int Main(string[] args) { if (args.Length > 0) { if (args[0].Equals("infinite")) { // To avoid potential issues with orphaned processes (say, the test exits before // exiting the process), we'll say "infinite" is actually 100 seconds. Sleep(100 * 1000); } else if (args[0].Equals("error")) { Console.Error.WriteLine(Name + " started error stream"); Console.Error.WriteLine(Name + " closed error stream"); Sleep(); } else if (args[0].Equals("input")) { string str = Console.ReadLine(); } else if (args[0].Equals("stream")) { Console.WriteLine(Name + " started"); Console.WriteLine(Name + " closed"); Sleep(); } else if (args[0].Equals("byteAtATime")) { var stdout = Console.OpenStandardOutput(); var bytes = new byte[] { 97, 0 }; //Encoding.Unicode.GetBytes("a"); for (int i = 0; i != bytes.Length; ++i) { stdout.WriteByte(bytes[i]); stdout.Flush(); Sleep(100); } } else if (args[0].Equals("ipc")) { using (var inbound = new AnonymousPipeClientStream(PipeDirection.In, args[1])) using (var outbound = new AnonymousPipeClientStream(PipeDirection.Out, args[2])) { // Echo 10 bytes from inbound to outbound for (int i = 0; i < 10; i++) { int b = inbound.ReadByte(); outbound.WriteByte((byte)b); } } } else { Console.WriteLine(string.Join(" ", args)); } } return 100; }
public static void StartClient(PipeDirection direction, SafePipeHandle clientPipeHandle) { using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(direction, clientPipeHandle)) { DoStreamOperations(client); } // If you don't see this message that means that this task crashed. Console.WriteLine("*** Client operations suceedeed. ***"); }
static void Main(string[] args) { if (args.Length > 0) { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { // Show that anonymous Pipes do not support Message mode. try { LogItLine("Setting ReadMode to \"Message\"."); pipeClient.ReadMode = PipeTransmissionMode.Message; } catch (NotSupportedException e) { LogItLine(string.Format("Execption:\n {0}", e.Message)); } LogItLine(string.Format("Current TransmissionMode: {0}.", pipeClient.TransmissionMode)); using (StreamReader sr = new StreamReader(pipeClient)) { // Display the read text to the console string temp; // Wait for 'sync message' from the server. do { LogItLine("Wait for sync..."); temp = sr.ReadLine(); } while (!temp.StartsWith("SYNC")); // Read the server data and echo to the console. while ((temp = sr.ReadLine()) != "END") { if (temp != null) { LogItLine("Echo: " + temp); Thread.Sleep(500); } else LogItLine("null"); } LogItLine("END..."); } } } LogIt("Press Enter to continue..."); Console.ReadLine(); }
private static void AnonymousWriter() { WriteLine("using anonymous pipe"); Write("pipe handle: "); string pipeHandle = ReadLine(); using (var pipeWriter = new AnonymousPipeClientStream(PipeDirection.Out, pipeHandle)) using (var writer = new StreamWriter(pipeWriter)) { for (int i = 0; i < 100; i++) { writer.WriteLine($"Message {i}"); Task.Delay(500).Wait(); } } }
private static int PingPong_OtherProcess(string inHandle, string outHandle) { // Create the clients associated with the supplied handles using (var inbound = new AnonymousPipeClientStream(PipeDirection.In, inHandle)) using (var outbound = new AnonymousPipeClientStream(PipeDirection.Out, outHandle)) { // Repeatedly read then write a byte from and to the server for (int i = 0; i < 10; i++) { int b = inbound.ReadByte(); outbound.WriteByte((byte)b); } } return SuccessExitCode; }
private void Writer() { WriteLine("anonymous pipe writer"); _pipeHandleSet.Wait(); var pipeWriter = new AnonymousPipeClientStream(PipeDirection.Out, _pipeHandle); using (var writer = new StreamWriter(pipeWriter)) { writer.AutoFlush = true; WriteLine("starting writer"); for (int i = 0; i < 5; i++) { writer.WriteLine($"Message {i}"); Task.Delay(500).Wait(); } writer.WriteLine("end"); } }
/// <summary> /// Reading by worker settings Chief passed. /// </summary> /// <param name="workerSettingsPipeHandle">Settings pipe handler.</param> /// <param name="workerLogPipe">Log redirector setting.</param> /// <param name="workerSettings">Worker settings.</param> /// <param name="chiefProcess">Chief process.</param> public static void ReadSettings( string workerSettingsPipeHandle, out ILog workerLogPipe, out ServerSettingsBase workerSettings, out Process chiefProcess) { using (var workerControlPipe = new AnonymousPipeClientStream(PipeDirection.In, workerSettingsPipeHandle)) { var binaryReader = new BinaryReader(workerControlPipe); workerLogPipe = new AnonymousPipeClientStreamLog(binaryReader.ReadString()); chiefProcess = Process.GetProcessById(binaryReader.ReadInt32()); workerLogPipe.Open(); workerSettings = (ServerSettingsBase)new BinaryFormatter().Deserialize(workerControlPipe); binaryReader.Dispose(); // because it closes underlying stream. } }
public static async Task ServerSendsByteClientReceivesAsync() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) { Assert.True(server.IsConnected); using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(server.GetClientHandleAsString())) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; await server.WriteAsync(sent, 0, 1); Assert.Equal(1, await client.ReadAsync(received, 0, 1)); Assert.Equal(sent[0], received[0]); } } }
public static void ClientSendsByteServerReceives() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.In)) { Assert.True(server.IsConnected); using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, server.ClientSafePipeHandle)) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; client.Write(sent, 0, 1); int bytesReceived = server.Read(received, 0, 1); Assert.Equal(1, bytesReceived); Assert.Equal(sent[0], received[0]); } } }
public static void ServerSendsByteClientReceives() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) { Assert.True(server.IsConnected); using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.In, server.GetClientHandleAsString())) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; server.Write(sent, 0, 1); Assert.Equal(1, client.Read(received, 0, 1)); Assert.Equal(sent[0], received[0]); } Assert.Throws<System.IO.IOException>(() => server.WriteByte(5)); } }
static void Main(string[] args) { using (AnonymousPipeClientStream pipeClient = new AnonymousPipeClientStream(PipeDirection.Out, args[0])) { using (StreamWriter pipeWriter = new StreamWriter(pipeClient)) { pipeWriter.WriteLine("HELLO"); pipeWriter.Flush(); Thread.Sleep(750); pipeWriter.WriteLine("FROM"); pipeWriter.Flush(); Thread.Sleep(750); pipeWriter.WriteLine("PIPE"); pipeWriter.Flush(); Thread.Sleep(750); pipeWriter.WriteLine("QUIT"); pipeWriter.Flush(); pipeClient.WaitForPipeDrain(); } } }
public static void Main(string[] args) { if (args.Length > 0) { using (var pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) { try { Console.WriteLine("[CLIENT] Setting ReadMode to \"Message\"."); pipeClient.ReadMode = PipeTransmissionMode.Message; } catch (NotSupportedException e) { Console.WriteLine("[CLIENT] Exception:\n {0}", e.Message); } Console.WriteLine("[CLIENT Current TransmissionMode: {0}.", pipeClient.TransmissionMode); using (var sr = new StreamReader(pipeClient)) { string temp; do { Console.WriteLine("[CLIENT] Wait for sync..."); temp = sr.ReadLine(); } while (!temp.StartsWith("SYNC")); while ((temp = sr.ReadLine()) != null) { Console.WriteLine("[CLIENT] Echo: " + temp); } } } } Console.Write("[CLIENT] Press Enter to continue..."); Console.ReadLine(); }
public static void ServerSendsByteClientReceivesAsync() { using (AnonymousPipeServerStream server = new AnonymousPipeServerStream(PipeDirection.Out)) { Assert.True(server.IsConnected); using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(server.GetClientHandleAsString())) { Assert.True(server.IsConnected); Assert.True(client.IsConnected); byte[] sent = new byte[] { 123 }; byte[] received = new byte[] { 0 }; Task writeTask = server.WriteAsync(sent, 0, 1); writeTask.Wait(); Task<int> readTask = client.ReadAsync(received, 0, 1); readTask.Wait(); Assert.Equal(1, readTask.Result); Assert.Equal(sent[0], received[0]); } } }
//RENDERER private NKRemotingProxy(string[] args) { NKLogging.log("+Started Renderer in new Process"); this.context = null; this._localHandlers = new Dictionary<string, NKScriptMessageHandler>(); this.cancelTokenSource = new CancellationTokenSource(); this.cancelToken = cancelTokenSource.Token; var outHandle = args[2]; var inHandle = args[1]; var syncPipeOut = new AnonymousPipeClientStream(PipeDirection.Out, outHandle); var syncPipeIn = new AnonymousPipeClientStream(PipeDirection.In, inHandle); this.syncPipeOut = syncPipeOut; this.syncPipeIn = syncPipeIn; syncPipeIn.ReadByte(); var handshake = readObject(syncPipeIn); if (handshake.command != NKRemotingMessage.Command.NKRemotingHandshake) { Environment.Exit(911); } var pipeName = handshake.args[0]; ns = handshake.args[1]; id = handshake.args[2]; NKScriptChannel.nativeFirstSequence = Int32.Parse(handshake.args[3]); handshake.args = new string[] { }; writeObject(syncPipeOut, handshake); var asyncPipe = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous | PipeOptions.WriteThrough); asyncPipe.Connect(); cancelToken.Register(requestSelfTeardown); this.asyncPipe = asyncPipe; Task.Factory.StartNew((s) => _processClientMessages(), null, cancelToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
private static int Run(string pipeHandleAsString) { int exitCode = -1; using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.Out, pipeHandleAsString)) { using (BinaryWriter bw = new BinaryWriter(pipeClient)) { try { exitCode = DecodeOne(bw); } catch (IOException ex) { LogWriteLine(string.Format(CultureInfo.InvariantCulture, "E: {0}", ex)); exitCode = -5; } catch (ArgumentException ex) { LogWriteLine(string.Format(CultureInfo.InvariantCulture, "E: {0}", ex)); exitCode = -5; } catch (UnauthorizedAccessException ex) { LogWriteLine(string.Format(CultureInfo.InvariantCulture, "E: {0}", ex)); exitCode = -5; } } } return exitCode; }
// AnonymousPipeClientStream owner; public UnixAnonymousPipeClient (AnonymousPipeClientStream owner, SafePipeHandle handle) { // this.owner = owner; this.handle = handle; }
static void Main(string[] args) { var commandLine = ParseCommandLine(args); if (commandLine.Contains("p")) { AnonymousPipeClientStream inPipeClient; try { inPipeClient = new AnonymousPipeClientStream(PipeDirection.In, commandLine.GetUnique("p")); } catch (ArgumentException) { ShowErrorMessage(); return; } var binFormatter = new BinaryFormatter(); var obj = binFormatter.Deserialize(inPipeClient); var serializedData = obj as byte[]; _xmlResults = new XmlDocument(); _xmlResults.Load(new MemoryStream(serializedData, false)); Console.WriteLine("Report: data received"); } if (commandLine.ShowHelp()) { Console.ReadKey(); return; } if (_xmlResults == null) { if (commandLine.Contains("r")) { FileStream xmlFile; try { xmlFile = new FileStream(commandLine.GetUnique("r"), FileMode.Open); } catch(FileNotFoundException e) { //todo: handle error throw; } _xmlResults = new XmlDocument(); _xmlResults.Load(xmlFile); } } var results = ParseXml(_xmlResults); foreach (var testItem in results) { CreatePlotAndSave(testItem); } Console.WriteLine("Processing finished. Press any key to exit..."); Console.ReadKey(); }
public HostProcess(string pipe1, string pipe2) { hostToWorkerPipe = new AnonymousPipeClientStream(PipeDirection.In, pipe1); workerToHostPipe = new AnonymousPipeClientStream(PipeDirection.Out, pipe2); this.Writer = new BinaryWriter(workerToHostPipe); }
private void pipeClientWorker() { using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, Options.Instance.PipeHandle)) { using (StreamReader sr = new StreamReader(pipeClient)) { string temp; // Read the server data. while ((temp = sr.ReadLine()) != null) { if (temp.ToUpper().StartsWith(CitacKarticaDictionary.DODAJ_CLANA.ToUpper())) { try { using (ISession session = NHibernateHelper.Instance.OpenSession()) using (session.BeginTransaction()) { CurrentSessionContext.Bind(session); string[] parts = temp.Split(' '); ClanDAO clanDAO = DAOFactoryFactory.DAOFactory.GetClanDAO(); Clan clan = clanDAO.FindById(int.Parse(parts[1])); CitacKarticaDictionary.Instance.DodajClanaSaKarticom(clan); } } catch (Exception ex) { MessageDialogs.showError(ex.Message, this.Text); } finally { CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory); } } else if (temp.ToUpper().StartsWith(CitacKarticaDictionary.DODAJ_UPLATE.ToUpper())) { try { using (ISession session = NHibernateHelper.Instance.OpenSession()) using (session.BeginTransaction()) { CurrentSessionContext.Bind(session); List<UplataClanarine> uplate = new List<UplataClanarine>(); string[] parts = temp.Split(' '); UplataClanarineDAO uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO(); for (int i = 1; i < parts.Length; ++i) { uplate.Add(uplataClanarineDAO.FindById(int.Parse(parts[i]))); } CitacKarticaDictionary.Instance.DodajUplate(uplate); } } catch (Exception ex) { MessageDialogs.showError(ex.Message, this.Text); } finally { CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory); } } else if (temp.ToUpper().StartsWith(CitacKarticaDictionary.UPDATE_NEPLACA_CLANARINU.ToUpper())) { string[] parts = temp.Split(' '); CitacKarticaDictionary.Instance.UpdateNeplacaClanarinu(int.Parse(parts[1]), bool.Parse(parts[2])); } else if (temp.ToUpper().StartsWith("CitacKarticaOpcije".ToUpper())) { string COMPortReader = String.Empty; string COMPortWriter = String.Empty; string PoslednjiDanZaUplate = String.Empty; string VelicinaSlovaZaCitacKartica = String.Empty; string PrikaziBojeKodOcitavanja = String.Empty; string PrikaziImeClanaKodOcitavanjaKartice = String.Empty; string PrikaziDisplejPrekoCelogEkrana = String.Empty; string SirinaDispleja = String.Empty; string VisinaDispleja = String.Empty; string[] parts = temp.Split(' '); for (int i = 1; i < parts.Length; i = i + 2) { if (parts[i].ToUpper() == "COMPortReader".ToUpper()) { COMPortReader = parts[i + 1]; } else if (parts[i].ToUpper() == "COMPortWriter".ToUpper()) { COMPortWriter = parts[i + 1]; } else if (parts[i].ToUpper() == "PoslednjiDanZaUplate".ToUpper()) { PoslednjiDanZaUplate = parts[i + 1]; } else if (parts[i].ToUpper() == "VelicinaSlovaZaCitacKartica".ToUpper()) { VelicinaSlovaZaCitacKartica = parts[i + 1]; } else if (parts[i].ToUpper() == "PrikaziBojeKodOcitavanja".ToUpper()) { PrikaziBojeKodOcitavanja = parts[i + 1]; } else if (parts[i].ToUpper() == "PrikaziImeClanaKodOcitavanjaKartice".ToUpper()) { PrikaziImeClanaKodOcitavanjaKartice = parts[i + 1]; } else if (parts[i].ToUpper() == "PrikaziDisplejPrekoCelogEkrana".ToUpper()) { PrikaziDisplejPrekoCelogEkrana = parts[i + 1]; } else if (parts[i].ToUpper() == "SirinaDispleja".ToUpper()) { SirinaDispleja = parts[i + 1]; } else if (parts[i].ToUpper() == "VisinaDispleja".ToUpper()) { VisinaDispleja = parts[i + 1]; } } Options.Instance.COMPortReader = int.Parse(COMPortReader); Options.Instance.COMPortWriter = int.Parse(COMPortWriter); Options.Instance.PoslednjiDanZaUplate = int.Parse(PoslednjiDanZaUplate); Options.Instance.VelicinaSlovaZaCitacKartica = int.Parse(VelicinaSlovaZaCitacKartica); Options.Instance.PrikaziBojeKodOcitavanja = bool.Parse(PrikaziBojeKodOcitavanja); Options.Instance.PrikaziImeClanaKodOcitavanjaKartice = bool.Parse(PrikaziImeClanaKodOcitavanjaKartice); Options.Instance.PrikaziDisplejPrekoCelogEkrana = bool.Parse(PrikaziDisplejPrekoCelogEkrana); Options.Instance.SirinaDispleja = int.Parse(SirinaDispleja); Options.Instance.VisinaDispleja = int.Parse(VisinaDispleja); } else if (temp.ToUpper().StartsWith("EXIT")) { Application.Exit(); } } } } }
static void Main( string[] args ) { #if DEBUG Console.WriteLine("PID {0} Debug", Process.GetCurrentProcess().Id ); #else Console.WriteLine("PID {0} Release", Process.GetCurrentProcess().Id ); #endif if (!args.Any(arg=>arg.StartsWith("--original="))) { // Assume we're the original process OriginalPath = Assembly.GetExecutingAssembly().GetName().CodeBase; // Relaunch and quit so that we don't lock the original executable: Relaunch(); return; } OriginalPath = args.First(arg=>arg.StartsWith("--original=")).Remove(0,"--original=".Length); if (args.Any(arg=>arg.StartsWith("--pipe="))) { var pipename = args.First(arg=>arg.StartsWith("--pipe=")).Remove(0,"--pipe=".Length); var pipe = new AnonymousPipeClientStream(pipename); var buffer = new byte[9001]; int read=0, length=0; do { read = pipe.Read(buffer,length,buffer.Length-length); length += read; } while ( read!=0 ); var si = new SocketInformation() { Options = SocketInformationOptions.Connected | SocketInformationOptions.UseOnlyOverlappedIO , ProtocolInformation = buffer.Take(length).ToArray() }; Connection = IrcConnection.RecoverConnectionFrom( new Socket(si) ); } else { Connection = new IrcConnection( "irc.afternet.org", 6667 ); } Connection.Listeners.Add(new CommandResponder(){State=Connection.Listeners[0] as IrcConnectionState}); Connection.BeginPumping(); Connection.WaitPumping(); if ( RelaunchFlag ) Relaunch(); }
// AnonymousPipeClientStream owner; public Win32AnonymousPipeClient(AnonymousPipeClientStream owner, SafePipeHandle handle) { // this.owner = owner; this.handle = handle; }
/// <summary> /// Initialize the control and start the Python engine. This is not in the constructor or /// OnLoaded because it breaks the VS designer. The main GUI window calls this. /// </summary> public void StartScripting() { pe = new PythonEngine(); pe.Sys.path.Add(Myro.Utilities.Params.BinPath); //pe.Sys.path.Add(Myro.Utilities.Params.PythonPath); //pe.Sys.path.Add("C:\\Users\\t-richr\\Myro-dev\\richard-dev-2\\Frontend\\Python"); //pe.Import("site"); pe.Sys.path.Add(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); var s = new AnonymousPipeServerStream(PipeDirection.In); stdout = s; stdoutpipe = new AnonymousPipeClientStream(PipeDirection.Out, s.ClientSafePipeHandle); readThreadOut = new Thread(new ThreadStart(delegate() { readLoop(stdout, Colors.Black); })); readThreadOut.Start(); var e = new AnonymousPipeServerStream(PipeDirection.In); stderr = e; stderrpipe = new AnonymousPipeClientStream(PipeDirection.Out, e.ClientSafePipeHandle); readThreadErr = new Thread(new ThreadStart(delegate() { readLoop(stderr, Colors.Crimson); })); readThreadErr.Start(); commandQueue = new Port<Command>(); commandDispatcherQueue = new DispatcherQueue("Python command queue", new Dispatcher(1, "Python command queue")); Arbiter.Activate(commandDispatcherQueue, Arbiter.Receive(true, commandQueue, commandHandler)); pe.SetStandardOutput(stdoutpipe); pe.SetStandardError(stderrpipe); //Console.SetOut(new StreamWriter(stdoutpipe)); //Console.SetError(new StreamWriter(stderrpipe)); //Console.OpenStandardOutput(); //Console.OpenStandardError(); historyBlock.Document.PageWidth = historyBlock.ViewportWidth; historyBlock.Document.Blocks.Clear(); paragraph = new Paragraph(); historyBlock.Document.Blocks.Add(paragraph); historyBlock.IsEnabled = true; }
/// <summary> /// Nimmt eine Anfrage entgegen. /// </summary> /// <param name="stream">Der Datenstrom, über den die Anfrage übertragen wird.</param> /// <returns>Die gewünschte Anfrage.</returns> public static Request ReceiveRequest( AnonymousPipeClientStream stream ) { // Process return (Request) ReadFromPipe( stream, m_Serializer ); }
public SubProcessClient(string[] args, RequestHandler handler) : base(handler) { PipeFromServer = new AnonymousPipeClientStream(PipeDirection.In, args[0]); PipeToServer = new AnonymousPipeClientStream(PipeDirection.Out, args[1]); Initialize(PipeFromServer, PipeToServer); }