Пример #1
0
        private static void ApplyData(IAsyncResult inResult)
        {
            MnDataBroker theReader = inResult.AsyncState as MnDataBroker;
            int          sizeReadData;

            try
            {
                sizeReadData = theReader.PipeServer.EndRead(inResult);
                if (sizeReadData == 0)
                {
                    theReader.PipeServer.Disconnect();
                }
            }
            catch (Exception theException)
            {
                theReader.PipeServer.Disconnect();
                System.Diagnostics.Debug.WriteLine(theException);
                return;
            }

            if (sizeReadData > 0)
            {
                lock (theReader.Queue)
                {
                    for (int i = 0; i < sizeReadData; i++)
                    {
                        theReader.Queue.Enqueue(theReader._buffer[i]);
                    }
                }
                theReader.HasData.Set();
                theReader.ReadPipeData();
            }
        }