public StartReceiveMessage ( ReceivedMessageHandler callback ) : void | ||
callback | ReceivedMessageHandler | |
Результат | void |
/// <summary> /// Initiates reading a message. Only one read operation can be active at a time. /// completionDelegate is invoked upon completion. /// </summary> protected void StartReadMessageInternal(AsyncCompletionDelegate <TRead> completionDelegate) { lock (myLock) { Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null"); CheckReadingAllowed(); call.StartReceiveMessage(HandleReadFinished); readCompletionDelegate = completionDelegate; } }
/// <summary> /// Requests receiving a next message. /// </summary> protected void StartReceiveMessage() { lock (myLock) { Preconditions.CheckState(started); Preconditions.CheckState(!disposed); Preconditions.CheckState(!errorOccured); Preconditions.CheckState(!readingDone); Preconditions.CheckState(!readPending); call.StartReceiveMessage(readFinishedHandler); readPending = true; } }
public Task <TRead> ReceiveMessageAsync() { lock (myLock) { CheckNotDisposed(); CheckStarted(); CheckNoError(); if (readingDone) { throw new InvalidOperationException("Already read the last message."); } if (readTcs != null) { throw new InvalidOperationException("Only one read can be pending at a time"); } call.StartReceiveMessage(readFinishedHandler); readTcs = new TaskCompletionSource <TRead>(); return(readTcs.Task); } }