Improve test

pull/2192/head
2dust 2022-04-12 20:24:48 +08:00
parent 73c79ca7bf
commit 38c739c45d
6 changed files with 35 additions and 23 deletions

View File

@ -767,8 +767,8 @@ namespace v2rayN.Forms
private void tsbTestMe_Click(object sender, EventArgs e)
{
string result = (new DownloadHandle()).RunAvailabilityCheck(null) + "ms";
AppendText(false, string.Format(ResUI.TestMeOutput, result));
var updateHandle = new UpdateHandle();
updateHandle.RunAvailabilityCheck(UpdateTaskHandler);
}
private void menuClearStatistic_Click(object sender, EventArgs e)
@ -1366,7 +1366,10 @@ namespace v2rayN.Forms
menuExit_Click(null, null);
}
};
(new UpdateHandle()).CheckUpdateGuiN(config, _updateUI);
Task.Run(() =>
{
(new UpdateHandle()).CheckUpdateGuiN(config, _updateUI);
});
}
private void tsbCheckUpdateCore_Click(object sender, EventArgs e)
@ -1399,7 +1402,10 @@ namespace v2rayN.Forms
AppendText(false, ResUI.MsgUpdateV2rayCoreSuccessfully);
}
};
(new UpdateHandle()).CheckUpdateCore(type, config, _updateUI);
Task.Run(() =>
{
(new UpdateHandle()).CheckUpdateCore(type, config, _updateUI);
});
}
private void tsbCheckUpdateGeo_Click(object sender, EventArgs e)

View File

@ -176,21 +176,17 @@ namespace v2rayN.Handler
webProxy = new WebProxy(Global.Loopback, httpPort);
}
Task<int> t = Task.Run(() =>
try
{
try
{
string status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out int responseTime);
bool noError = Utils.IsNullOrEmpty(status);
return noError ? responseTime : -1;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return -1;
}
});
return t.Result;
string status = GetRealPingTime(Global.SpeedPingTestUrl, webProxy, out int responseTime);
bool noError = Utils.IsNullOrEmpty(status);
return noError ? responseTime : -1;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return -1;
}
}
catch (Exception ex)
{

View File

@ -250,8 +250,8 @@ namespace v2rayN.Handler
File.Delete(targetPath);
}
File.Move(fileName, targetPath);
//_updateFunc(true, "");
}
//_updateFunc(true, "");
}
}
catch (Exception ex)
{
@ -272,6 +272,16 @@ namespace v2rayN.Handler
}
public void RunAvailabilityCheck(Action<bool, string> update)
{
Task.Run(() =>
{
var time = (new DownloadHandle()).RunAvailabilityCheck(null);
update(false, string.Format(ResUI.TestMeOutput, time));
});
}
#region private
private async void CheckUpdateAsync(ECoreType type)

View File

@ -953,7 +953,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 The ping of current service: {0} 的本地化字符串。
/// 查找类似 The ping of current service: {0} ms 的本地化字符串。
/// </summary>
internal static string TestMeOutput {
get {

View File

@ -356,7 +356,7 @@
<value>Scan import URL successfully</value>
</data>
<data name="TestMeOutput" xml:space="preserve">
<value>The ping of current service: {0}</value>
<value>The ping of current service: {0} ms</value>
</data>
<data name="OperationSuccess" xml:space="preserve">
<value>Operation success</value>

View File

@ -356,7 +356,7 @@
<value>扫描导入URL成功</value>
</data>
<data name="TestMeOutput" xml:space="preserve">
<value>当前服务的真连接延迟: {0}</value>
<value>当前服务的真连接延迟: {0} ms</value>
</data>
<data name="OperationSuccess" xml:space="preserve">
<value>操作成功</value>