We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 214a09b commit eb0ef90Copy full SHA for eb0ef90
1 file changed
v2rayN/ServiceLib/ViewModels/MsgViewModel.cs
@@ -86,15 +86,25 @@ private void EnqueueQueueMsg(string msg)
86
}
87
catch (Exception ex)
88
{
89
- _queueMsg.Enqueue(ex.Message);
+ EnqueueWithLimit(ex.Message);
90
_lastMsgFilterNotAvailable = true;
91
92
93
94
- _queueMsg.Enqueue(msg);
+ EnqueueWithLimit(msg);
95
if (!msg.EndsWith(Environment.NewLine))
96
97
- _queueMsg.Enqueue(Environment.NewLine);
+ EnqueueWithLimit(Environment.NewLine);
98
+ }
99
100
+
101
+ private void EnqueueWithLimit(string item)
102
+ {
103
+ _queueMsg.Enqueue(item);
104
105
+ while (_queueMsg.Count > NumMaxMsg)
106
107
+ _queueMsg.TryDequeue(out _);
108
109
110
0 commit comments