mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-30 04:08:49 +00:00
Optimize code
This commit is contained in:
parent
1a33c598e8
commit
c49ba735a0
1 changed files with 10 additions and 6 deletions
|
@ -9,7 +9,6 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
private ConcurrentQueue<string> _queueMsg = new();
|
private ConcurrentQueue<string> _queueMsg = new();
|
||||||
private int _numMaxMsg = 500;
|
private int _numMaxMsg = 500;
|
||||||
private string _lastMsgFilter = string.Empty;
|
|
||||||
private bool _lastMsgFilterNotAvailable;
|
private bool _lastMsgFilterNotAvailable;
|
||||||
private bool _blLockShow = false;
|
private bool _blLockShow = false;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.MsgFilter)
|
x => x.MsgFilter)
|
||||||
.Subscribe(c => _config.MsgUIItem.MainMsgFilter = MsgFilter);
|
.Subscribe(c => DoMsgFilter());
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.AutoRefresh,
|
x => x.AutoRefresh,
|
||||||
|
@ -77,8 +76,7 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task EnqueueQueueMsg(string msg)
|
private async Task EnqueueQueueMsg(string msg)
|
||||||
{
|
{
|
||||||
//filter msg
|
//filter msg
|
||||||
if (MsgFilter != _lastMsgFilter) _lastMsgFilterNotAvailable = false;
|
if (MsgFilter.IsNotEmpty() && !_lastMsgFilterNotAvailable)
|
||||||
if (Utils.IsNotEmpty(MsgFilter) && !_lastMsgFilterNotAvailable)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -87,12 +85,12 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_queueMsg.Enqueue(ex.Message);
|
||||||
_lastMsgFilterNotAvailable = true;
|
_lastMsgFilterNotAvailable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lastMsgFilter = MsgFilter;
|
|
||||||
|
|
||||||
//Enqueue
|
//Enqueue
|
||||||
if (_queueMsg.Count > _numMaxMsg)
|
if (_queueMsg.Count > _numMaxMsg)
|
||||||
|
@ -113,5 +111,11 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
_queueMsg.Clear();
|
_queueMsg.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DoMsgFilter()
|
||||||
|
{
|
||||||
|
_config.MsgUIItem.MainMsgFilter = MsgFilter;
|
||||||
|
_lastMsgFilterNotAvailable = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue