Пример #1
0
        /*
         * Below function reads the data from the server till terminator is reached
         */
        //public byte[] Receive(string terminator)
        //{
        //    byte[] bb = Read();
        //    if (bb != null)
        //    {
        //        while (bb[bb.Length - 1] != Convert.ToByte(terminator))
        //        {
        //            Array.Copy(bb, 0, result, index, bb.Length);
        //            index += bb.Length;
        //            bb = Read();
        //            if (bb == null)
        //            {
        //                index = 0;
        //                return null;
        //            }
        //        }
        //        Array.Copy(bb, 0, result, index, bb.Length);
        //        index += bb.Length;
        //    }
        //    else
        //    {
        //        index = 0;
        //        return null;
        //    }
        //    Array.Resize(ref result, index);
        //    index = 0;
        //    return result;
        //}

        public string ReceiveAsync(cbFncStringToRead fnx, string comparer)
        {
            while (true)
            {
                fnx(Receive("}}}"));
            }
        }
Пример #2
0
 public void AsyncRead(cbFncStringToRead read)
 {
     readbytes = new Thread(() => ReceiveAsync(read, "}}}"));
     readbytes.Start();
 }