예제 #1
0
파일: File.cs 프로젝트: PlumpMath/sharpuv
        private void OnWrite(IntPtr req)
        {
            var callback = _writeCallback;

            _writeCallback = null;

            callback.Invoke(this.FreeRequest(req), this.OnWrite, this.DataWrite);
        }
예제 #2
0
파일: File.cs 프로젝트: PlumpMath/sharpuv
        private void OnRead(IntPtr req)
        {
            var callback = _readCallback;

            _readCallback = null;

            callback.Invoke(this.FreeReadRequest(req), this.OnRead, this.DataRead);
        }
예제 #3
0
파일: File.cs 프로젝트: PlumpMath/sharpuv
        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;
            }
        }
예제 #4
0
파일: File.cs 프로젝트: PlumpMath/sharpuv
        /// <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;
            }
        }
예제 #5
0
 public void ReadStop()
 {
     CheckError(Uvi.uv_read_stop(this.Handle));
     _isReading    = false;
     _readCallback = null;
 }
예제 #6
0
 public void ReadStart(Action <UvDataArgs> callback = null)
 {
     CheckError(Uvi.uv_read_start(this.Handle, _allocDelegate, _readDelegate));
     _isReading    = true;
     _readCallback = new UvDataCallback(this, callback);
 }