Beispiel #1
0
 public void Write(byte[] buffer, int offset, int count)
 {
     var state = new StateObject();
     lock (_streamLock)
     {
         _stream.BeginWrite(buffer, offset, count, WriteCallback, state);
     }
     state.Done.WaitOne();
 }
Beispiel #2
0
 public int Read(byte[] buffer, int offset, int count)
 {
     var state = new StateObject();
     lock (_streamLock)
     {
         _stream.BeginRead(buffer, offset, count, ReadCallback, state);
     }
     state.Done.WaitOne();
     return state.BytesRead;
 }
Beispiel #3
0
        public int ReadByte()
        {
            byte[] buffer = new byte[1];

            var state = new StateObject();
            lock (_streamLock)
            {
                _stream.BeginRead(buffer, 0, 1, ReadCallback, state);
            }
            state.Done.WaitOne();
            return buffer[0];
        }