diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 56c63c23..e4927b45 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -1316,9 +1316,28 @@ namespace v2rayN.Forms private void tsbSubUpdate_Click(object sender, EventArgs e) { - UpdateSubscriptionProcess(); + VmessItem item = config.vmess[config.index]; + var remarks = item.remarks; + var handle = new UpdateHandle(); + void _updateUIAndReselect(bool success, string msg) + { + AppendText(false, msg); + if (success) + { + RefreshServers(); + } + if (handle.updateSubscriptionProcessCompleted) + { + // wait for above fxcking async program to complete + int index = FindIndexByRemarks(remarks); + SetDefaultServer(index); + AppendText(false, $"{UIRes.I18N("MsgUpdateSubscriptionEndReslectLast")}"); + RefreshServers(); + handle.updateSubscriptionProcessCompleted = false; + } + }; + handle.UpdateSubscriptionProcess(config, _updateUIAndReselect); } - /// /// the subscription update process /// diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index 2a35d676..d5814840 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -14,7 +14,7 @@ namespace v2rayN.Handler { Action _updateFunc; private Config _config; - + public bool updateSubscriptionProcessCompleted = false; public event EventHandler AbsoluteCompleted; public class ResultEventArgs : EventArgs