Exemplo n.º 1
0
 public void ReadStop()
 {
     CheckError(Uvi.uv_read_stop(this.Handle));
     _isReading = false;
     _readCallback = null;
 }
Exemplo n.º 2
0
 public void ReadStart(Action<UvDataArgs> callback = null)
 {
     CheckError(Uvi.uv_read_start(this.Handle, _allocDelegate, _readDelegate));
     _isReading = true;
     _readCallback = new UvDataCallback(this, callback);
 }
Exemplo n.º 3
0
        private void OnWrite(IntPtr req)
        {
            var callback = _writeCallback;
            _writeCallback = null;

            callback.Invoke(this.FreeRequest(req), this.OnWrite, this.DataWrite);
        }
Exemplo n.º 4
0
        private void OnRead(IntPtr req)
        {
            var callback = _readCallback;
            _readCallback = null;

            callback.Invoke(this.FreeReadRequest(req), this.OnRead, this.DataRead);
        }
Exemplo n.º 5
0
        public void Write(byte[] data, int offset, int length, Action<UvDataArgs> callback = null)
        {
            if (this.Status != FileStatus.Open)
                throw new InvalidOperationException("File handle must be open in order to write data");

            IntPtr req = IntPtr.Zero;

            try
            {
                req = this.CreateRequest(data, offset, length);
                CheckError(Uvi.uv_fs_write(this.Loop.Handle, req, _file, new[] { this.Loop.Requests[req] }, 1, -1, _writeDelegate));
                _writeCallback = new UvDataCallback(this, callback, data);
            }
            catch (Exception)
            {
                this.FreeRequest(req);
                throw;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Read from the file
        /// </summary>
        public void Read(uint length, Action<UvDataArgs> callback = null)
        {
            if (this.Status != FileStatus.Open)
                throw new InvalidOperationException("File handle must be open in order to read data");

            IntPtr req = IntPtr.Zero;

            try
            {
                req = this.CreateRequest(length);
                CheckError(Uvi.uv_fs_read(this.Loop.Handle, req, _file, new[] { this.Loop.Requests[req] }, 1, -1, _readDelegate));
                _readCallback = new UvDataCallback(this, callback);
            }
            catch (Exception)
            {
                this.FreeRequest(req);
                throw;
            }
        }