private void ReadData(object stateObject) { try { if (fPreviousPacket == null) { fConnector.fMyTCPClient.OnDataReceive(fConnector, fData); } else { fPreviousPacket.fDone.WaitOne(); if (!fCancel && !fPreviousPacket.fCancel) { fConnector.fMyTCPClient.OnDataReceive(fConnector, fData); } else { fCancel = true; } } } catch (Exception ex) { } if (fPreviousPacket != null) { fPreviousPacket = null; } fDone.Set(); }
/// <summary> /// Constructs a new incoming packet received by a TCP connector. /// Use this class to receive data from a server. /// This is an incoming message that will remain in the client's thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="connector">The TCP Connector where this message belongs to.</param> /// <param name="data">DataFrame class.</param> /// <param name="previousPacket">The previous incoming message of the TCP Connector.</param> public IncomingTCPClientPacket(TCPConnector connector, DataFrame data, IncomingTCPClientPacket previousPacket) { fConnector = connector; fData = data; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData)); }