public IAsyncResult GetAsyncResult(AsyncCallback callback, object asyncState) { if (_asyncResult != null) throw new ProtoChannelException("BeginGetStream cannot be called multiple times"); _asyncResult = new AsyncResultImpl<PendingReceiveStream>(callback, asyncState); if (IsCompleted) CompleteAsyncResult(true); return _asyncResult; }
public IAsyncResult BeginSendMessage(object message, AsyncCallback callback, object asyncState) { VerifyNotDisposed(); lock (_syncRoot) { var asyncMessage = new AsyncResultImpl<object>(callback, asyncState); uint associationId = _nextCallbackAssociationId++; _pendingCallbacks.Add(associationId, asyncMessage); _messages.Enqueue(new PendingDownstreamMessage(MessageKind.Request, associationId, message)); SendMessages(); return asyncMessage; } }