예제 #1
0
        private async void fetchServerInfo(object parameter)
        {
            DialogButton dialog = new DialogButton(sr_ask_keep_info_title, sr_ask_keep_info_message);

            dialog.ShowDialog();
            if (!(dialog.CancelableResult is bool keep))
            {
                return;
            }

            isFetchInProcess = true;
            App.UpdateProgress(40);

            await Task.Run(() =>
            {
                foreach (ServerProfileView serverInfo in ObServerInfoList)
                {
                    // isFetchInProcess is also use to cancel task
                    if (isFetchInProcess == false)
                    {
                        return;
                    }

                    serverInfo.UpdateIPInfo(!keep);
                }
            });

            try
            {
                // it will update the server info only if the server is not changed
                ServerProfileView serverInfo = ObServerInfoList.First(x => x.HostIP == config.RemoteServer.vHostIP && x.Port == config.RemoteServer.vPort);
                App.UpdateTransmitServer(serverInfo.vServerProfile);
            }
            catch (Exception) { }

            isFetchInProcess = false;
            App.UpdateProgress(-40);
            CommandManager.InvalidateRequerySuggested();
        }