Skip to content

Commit eb0ef90

Browse files
committed
Bug fix
2dust#8906
1 parent 214a09b commit eb0ef90

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

v2rayN/ServiceLib/ViewModels/MsgViewModel.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,25 @@ private void EnqueueQueueMsg(string msg)
8686
}
8787
catch (Exception ex)
8888
{
89-
_queueMsg.Enqueue(ex.Message);
89+
EnqueueWithLimit(ex.Message);
9090
_lastMsgFilterNotAvailable = true;
9191
}
9292
}
9393

94-
_queueMsg.Enqueue(msg);
94+
EnqueueWithLimit(msg);
9595
if (!msg.EndsWith(Environment.NewLine))
9696
{
97-
_queueMsg.Enqueue(Environment.NewLine);
97+
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 _);
98108
}
99109
}
100110

0 commit comments

Comments
 (0)