コード例 #1
0
ファイル: PassivePmlChannel.cs プロジェクト: UCIS/UCIS.Core
        private void AsyncReadMessage(object state)
        {
            ReadMessageAsyncResult ar = (ReadMessageAsyncResult)state;

            try {
                PmlElement message = ReadMessage();
                ar.SetCompleted(false, null, message);
            } catch (Exception ex) {
                ar.SetCompleted(false, ex, null);
            }
        }
コード例 #2
0
ファイル: ActivePmlChannel.cs プロジェクト: UCIS/UCIS.Core
        public IAsyncResult BeginReadMessage(AsyncCallback callback, object state)
        {
            ReadMessageAsyncResult ar;
            Boolean completed = false;

            lock (_queue) {
                if (!IsOpen)
                {
                    throw new InvalidOperationException("The channel is not open");
                }
                if (_asyncWait != null)
                {
                    throw new InvalidOperationException("Another asynchronous operation is in progress");
                }
                ar = new ReadMessageAsyncResult(callback, state);
                if (_queue.Count == 0)
                {
                    _asyncWait = ar;
                }
                else
                {
                    ar.Message = _queue.Dequeue();
                    completed  = true;
                }
            }
            if (completed)
            {
                ar.SetCompleted(true, null);
            }
            return(ar);
        }