private void OnWrite(IntPtr req) { var callback = _writeCallback; _writeCallback = null; callback.Invoke(this.FreeRequest(req), this.OnWrite, this.DataWrite); }
private void OnRead(IntPtr req) { var callback = _readCallback; _readCallback = null; callback.Invoke(this.FreeReadRequest(req), this.OnRead, this.DataRead); }
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; } }
/// <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; } }
public void ReadStop() { CheckError(Uvi.uv_read_stop(this.Handle)); _isReading = false; _readCallback = null; }
public void ReadStart(Action <UvDataArgs> callback = null) { CheckError(Uvi.uv_read_start(this.Handle, _allocDelegate, _readDelegate)); _isReading = true; _readCallback = new UvDataCallback(this, callback); }