コード例 #1
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;
            }
        }