public static void ReadAsync(TcpClient client, LockableBool isDone, LockableObject <byte[]> output, out Thread ReadThread) { if (isDone == null) { isDone = new LockableBool(); } if (output == null) { output = new LockableObject <byte[]>(); } ReadThread = new Thread(() => _ReadAsnyc(client, output, isDone)); ReadThread.Start(); }
void HandleIncomingConnection(TcpClient client) { Stopwatch timeout = Stopwatch.StartNew(); LockableBool isdone = new LockableBool(); byte[] output = TCPMessageHandler.Read(client); //LockableObject<byte[]> output = null; //Thread thread; //TCPMessageHandler.Read(client, isdone, output, out thread); //while (!isdone) //{ // Thread.Sleep(1); // if (timeout.ElapsedMilliseconds > this.timeout) // { // try { thread.Abort(); thread = null; } catch { } // TCPMessageHandler.CloseConnection(client); // return; // } //} SharpSerializer package = SharpSerializer.Create(output); try { HandleIncomingConnectionRequest(package, client); } catch (Exception e) { TCPMessageHandler.CloseConnection(client); } package.Post(); }
private static void _ReadAsnyc(TcpClient client, LockableObject <byte[]> output, LockableBool isDone) { byte[] go = Read(client); output.Value = go; isDone.Value = true; }