Exemplo n.º 1
0
 private void SerialStream_WaitForConnection(IAsyncResult asyncResult)
 {
     try
     {
         SerialStream.EndWaitForConnection(asyncResult);
         SerialStream.BeginRead(buffer, 0, 1, SerialStream_Read, null);
     }
     catch { }
 }
Exemplo n.º 2
0
        private void SerialStream_Read(IAsyncResult asyncResult)
        {
            int count = SerialStream.EndRead(asyncResult);

            if (count != 1)
            {
                try
                {
                    SerialStream.Close();
                    Gdb.Dispose();
                }
                catch { }

                SerialStream = new NamedPipeServerStream("System", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
                SerialStream.BeginWaitForConnection(SerialStream_WaitForConnection, null);

                return;
            }

            SerialStream_ReadByte(buffer[0]);

            SerialStream.BeginRead(buffer, 0, 1, SerialStream_Read, null);
        }