public void Run() { while (allReceived.Read() < msgCount) { try { Msg msg = sub.NextMessage(500); while (msg != null) { received++; allReceived.Increment(); datas.Add(Encoding.UTF8.GetString(msg.Data)); msg.Ack(); msg = sub.NextMessage(500); } } catch (NATSTimeoutException) { // timeout is acceptable, means no messages available. } } }
internal static long Next() => Generator.Increment();