refine code

This commit is contained in:
YFdyh000 2020-03-20 11:30:21 +08:00
parent a6664fbc01
commit d8458e84f4

View file

@ -109,17 +109,14 @@ namespace v2rayN.Handler
//Thread.Sleep(5000); //Thread.Sleep(5000);
int httpPort = _config.GetLocalPort("speedtest"); int httpPort = _config.GetLocalPort("speedtest");
Task[] tasks = new Task[_selecteds.Count]; List<Task> tasks = new List<Task>();
int i = -1;
foreach (int itemIndex in _selecteds) foreach (int itemIndex in _selecteds)
{ {
if (_config.vmess[itemIndex].configType == (int)EConfigType.Custom) if (_config.vmess[itemIndex].configType == (int)EConfigType.Custom)
{ {
continue; continue;
} }
tasks.Add(Task.Run(() =>
i++;
tasks[i] = Task.Run(() =>
{ {
try try
{ {
@ -133,12 +130,10 @@ namespace v2rayN.Handler
{ {
Utils.SaveLog(ex.Message, ex); Utils.SaveLog(ex.Message, ex);
} }
}); }));
//Thread.Sleep(100); //Thread.Sleep(100);
} }
Task.WaitAll(tasks); Task.WaitAll(tasks.ToArray());
Thread.Sleep(100);
} }
catch (Exception ex) catch (Exception ex)
{ {