mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-28 16:14:58 +03:00
Code optimization, function asynchrony
This commit is contained in:
@@ -14,9 +14,14 @@ namespace ServiceLib.Handler
|
||||
|
||||
public ProfileExHandler()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
private async Task Init()
|
||||
{
|
||||
await InitData();
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Init();
|
||||
while (true)
|
||||
{
|
||||
await SaveQueueIndexIds();
|
||||
@@ -25,7 +30,7 @@ namespace ServiceLib.Handler
|
||||
});
|
||||
}
|
||||
|
||||
private async Task Init()
|
||||
private async Task InitData()
|
||||
{
|
||||
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
public List<ServerStatItem> ServerStat => _lstServerStat;
|
||||
|
||||
public void Init(Config config, Action<ServerSpeedItem> updateFunc)
|
||||
public async Task Init(Config config, Action<ServerSpeedItem> updateFunc)
|
||||
{
|
||||
_config = config;
|
||||
_updateFunc = updateFunc;
|
||||
@@ -23,7 +23,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
InitData();
|
||||
await InitData();
|
||||
|
||||
_statisticsV2Ray = new StatisticsV2rayService(config, UpdateServerStatHandler);
|
||||
_statisticsSingbox = new StatisticsSingboxService(config, UpdateServerStatHandler);
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
private static readonly Lazy<TaskHandler> _instance = new(() => new());
|
||||
public static TaskHandler Instance => _instance.Value;
|
||||
|
||||
public TaskHandler()
|
||||
{
|
||||
}
|
||||
|
||||
public void RegUpdateTask(Config config, Action<bool, string> updateFunc)
|
||||
{
|
||||
Task.Run(() => UpdateTaskRunSubscription(config, updateFunc));
|
||||
|
||||
Reference in New Issue
Block a user