Exemple #1
0
        private void OnFlushTick(object sender, EventArgs e)
        {
            var list = new List <ChatMessage>();

            while (_mainQueue.TryDequeue(out var m))
            {
                list.Add(m);
            }

            ChatMessages.AddBatch(list);
            if (ChatMessages.Count > App.Settings.MaxMessages)
            {
                var toRemove = new List <ChatMessage>();
                for (int i = 0; i < list.Count; i++)
                {
                    var target = ChatMessages[ChatMessages.Count - 1];
                    target.Dispose();
                    toRemove.Add(target);
                }
                ChatMessages.RemoveBatch(toRemove);
            }
            N(nameof(MessageCount));
        }