private void RunReceiverProcessCallback(object state, CancellationToken token) { buffer = HelperTools.RentBuffer(HelperTools.SIZE_BYTES); Socket socket = (Socket)state; //EndPoint e = new IPEndPoint(IPAddress.Any, networkPort); long time; int n_bytes; while (!cancelToken.IsCancellationRequested) { if (socket != null) { try { n_bytes = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None); time = HelperTools.GetLocalMicrosTime(); if (n_bytes > 0) { // Fire Event DataReadyEvent?.Invoke(networkIp, networkPort, time, buffer, 0, n_bytes, ID, ipChunks); } } catch (Exception ee) { } } } HelperTools.ReturnBuffer(buffer); }