コード例 #1
0
        /// <seealso cref="Genetibase.NuGenHL7.protocol.AbstractTransport.doReceive()">
        /// </seealso>
        public override NuGenTransportable doReceive()
        {
            if (myConnectOnReceive)
            {
                makeConnection();
            }

            System.Text.StringBuilder response = new System.Text.StringBuilder();

            try
            {
                System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.BufferedStream(myConnection.GetResponse().GetResponseStream()), System.Text.Encoding.Default);

                char[] buf       = new char[myBufferSize];
                int    bytesRead = 0;

                NuGenIntRef bytesReadRef = new NuGenIntRef();

                while (bytesRead >= 0)
                {
                    try
                    {
                        NuGenReaderThread readerThread = new NuGenReaderThread(in_Renamed, buf, bytesReadRef);
                        readerThread.Start();
                        readerThread.Join(10000);

                        bytesRead = bytesReadRef.Value;

                        if (bytesRead == 0)
                        {
                            throw new NuGenTransportException("Timeout waiting for response");
                        }
                    }
                    catch (System.Threading.ThreadInterruptedException)
                    {
                    }

                    if (bytesRead > 0)
                    {
                        response.Append(buf, 0, bytesRead);
                    }
                }

                in_Renamed.Close();
            }
            catch (System.IO.IOException)
            {
            }

            if (response.Length == 0)
            {
                throw new NuGenTransportException("Timeout waiting for response");
            }

            return(new NuGenTransportableImpl(response.ToString()));
        }
コード例 #2
0
 /// <summary> Creates a new instance
 ///
 /// </summary>
 /// <param name="theReader">the reader for this thread
 /// </param>
 /// <param name="theBuffer">the buffer for reading
 /// </param>
 /// <param name="theBytesReadRef">stores the number of bytes read
 /// </param>
 public NuGenReaderThread(System.IO.StreamReader theReader, char[] theBuffer, NuGenIntRef theBytesReadRef)
 {
     this.myReader       = theReader;
     this.myBuffer       = theBuffer;
     this.myBytesReadRef = theBytesReadRef;
 }
コード例 #3
0
		/// <summary> Creates a new instance
		/// 
		/// </summary>
		/// <param name="theReader">the reader for this thread
		/// </param>
		/// <param name="theBuffer">the buffer for reading
		/// </param>
		/// <param name="theBytesReadRef">stores the number of bytes read
		/// </param>
		public NuGenReaderThread(System.IO.StreamReader theReader, char[] theBuffer, NuGenIntRef theBytesReadRef)
		{
			this.myReader = theReader;
			this.myBuffer = theBuffer;
			this.myBytesReadRef = theBytesReadRef;
		}