public IAsyncResult BeginClose () { TransparentStreamCloseRequestMessage request = new TransparentStreamCloseRequestMessage (Guid.NewGuid (), streamID); TransparentStreamAsyncResult result = new TransparentStreamAsyncResult (null); if (!pendingCloseRequests.TryAdd (request.ID, result)) { throw new Exception ("request failed before sending."); } objectBusSession.SendMessage (request); return result; }
public IAsyncResult BeginSetReadTimeout (int value) { TransparentStreamSetReadTimeoutRequestMessage request = new TransparentStreamSetReadTimeoutRequestMessage (Guid.NewGuid (), streamID, value); TransparentStreamAsyncResult result = new TransparentStreamAsyncResult (null); if (!pendingSetReadTimeoutRequests.TryAdd (request.ID, result)) { throw new Exception ("request failed before sending."); } objectBusSession.SendMessage (request); return result; }
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state) { TransparentStreamReadRequestMessage request = new TransparentStreamReadRequestMessage (Guid.NewGuid (), streamID, count); TransparentStreamAsyncResult result = new TransparentStreamAsyncResult (callback, state); if (!pendingReadRequests.TryAdd (request.ID, new Tuple <TransparentStreamAsyncResult, byte[], int, int> (result, buffer, offset, count))) { throw new Exception ("request failed before sending."); } objectBusSession.SendMessage (request); return result; }
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state) { byte[] nbuf = new byte[count]; System.Buffer.BlockCopy (buffer, offset, nbuf, 0, count); TransparentStreamWriteRequestMessage request = new TransparentStreamWriteRequestMessage (Guid.NewGuid (), streamID, nbuf); TransparentStreamAsyncResult result = new TransparentStreamAsyncResult (null); if (!pendingWriteRequests.TryAdd (request.ID, result)) { throw new Exception ("request failed before sending."); } objectBusSession.SendMessage (request); return result; }
public IAsyncResult BeginSeek (long offset, System.IO.SeekOrigin origin) { TransparentStreamSeekRequestMessage request = new TransparentStreamSeekRequestMessage (Guid.NewGuid (), streamID, offset, origin); TransparentStreamAsyncResult result = new TransparentStreamAsyncResult (null); if (!pendingSeekRequests.TryAdd (request.ID, result)) { throw new Exception ("request failed before sending."); } objectBusSession.SendMessage (request); return result; }