public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { //return inStream.BeginRead(buffer, offset, count, callback, state); //if (!this.CanRead) //{ // // __Error.ReadNotSupported(); //} SynchronousAsyncResult ar = new SynchronousAsyncResult(state, false); try { //int num = Read(buffer, offset, count); int num = inStream.Read(buffer, offset, count); ar.m_NumRead = num; ar.m_IsCompleted = true; //ar._waitHandle.Set(); } catch (IOException exception) { //ar._exception = exception; } if (callback != null) { callback(ar); } return ar; }
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { SynchronousAsyncResult ar = new SynchronousAsyncResult(state, true); try { //Write(buffer, offset, count); outStream.Write(buffer, offset, count); ar.m_IsCompleted = true; //ar._waitHandle.Set(); } catch (IOException exception) { //ar._exception = exception; } if (callback != null) { callback(ar); //callback.BeginInvoke(ar, null, null); } return ar; }