Ejemplo n.º 1
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;
            }
        }