private void BtnRefreshVer_Click(object sender, System.EventArgs e) { var elRefresh = btnRefreshVer; var elCboxVer = cboxVer; elRefresh.Enabled = false; VgcApis.Misc.Utils.RunInBackground(() => { int proxyPort = -1; if (chkUseProxy.Checked) { proxyPort = servers.GetAvailableHttpProxyPort(); } var versions = Misc.Utils.GetOnlineV2RayCoreVersionList(proxyPort); if (versions != null && versions.Count > 0) { setting.SaveV2RayCoreVersionList(versions); } VgcApis.Misc.UI.Invoke(() => elRefresh.Enabled = true); VgcApis.Misc.UI.Invoke(() => { if (versions.Count > 0) { Misc.UI.FillComboBox(elCboxVer, versions); } else { MessageBox.Show(I18N.GetVersionListFail); } }); }); }
private void BtnRefreshVer_Click(object sender, System.EventArgs e) { btnRefreshVer.Enabled = false; var sourceUrl = VgcApis.Models.Consts.Core.GetSourceUrlByIndex(cboxDownloadSource.SelectedIndex); int proxyPort = chkUseProxy.Checked ? servers.GetAvailableHttpProxyPort() : -1; Action <List <string> > done = (versions) => { btnRefreshVer.Enabled = true; if (versions.Count > 0) { Misc.UI.FillComboBox(cboxVer, versions); } else { MessageBox.Show(I18N.GetVersionListFail); } }; Action worker = () => { var versions = Misc.Utils.GetOnlineV2RayCoreVersionList(proxyPort, sourceUrl); if (versions != null && versions.Count > 0) { setting.SaveV2RayCoreVersionList(versions); } VgcApis.Misc.UI.Invoke(() => done(versions)); }; VgcApis.Misc.Utils.RunInBackground(worker); }
int GetAvailableHttpProxyPort() { if (!chkSubsIsUseProxy.Checked) { return(-1); } var port = servers.GetAvailableHttpProxyPort(); if (port > 0) { return(port); } VgcApis.Misc.UI.MsgBoxAsync(I18N.NoQualifyProxyServer); return(-1); }
int GetAvailableHttpProxyPort() { if (!chkSubsIsUseProxy.Checked) { return(-1); } var port = servers.GetAvailableHttpProxyPort(); if (port > 0) { return(port); } VgcApis.Misc.Utils.RunInBackground( () => MessageBox.Show( I18N.NoQualifyProxyServer)); return(-1); }