StartReceiveMessage() public method

public StartReceiveMessage ( ReceivedMessageHandler callback ) : void
callback ReceivedMessageHandler
return void
Ejemplo n.º 1
0
        /// <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;
            }
        }
Ejemplo n.º 2
0
        /// <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;
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }