public override bool Action(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_SHOW) { if (Utils.API.GeocachingLiveV6.CheckAPIAccessAvailable(Core, false)) { bool perform = true; if (Properties.Settings.Default.ShowSettingsDialog) { using (SettingsForm dlg = new SettingsForm()) { perform = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } if (perform) { using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(Core)) { _errormessage = ""; _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.threadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } } } result = true; } return result; }
public async override Task<bool> ActionAsync(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_SHOW) { if (Utils.API.GeocachingLiveV6.CheckAPIAccessAvailable(Core, false)) { bool perform = true; if (PluginSettings.Instance.ShowSettingsDialog) { using (SettingsForm dlg = new SettingsForm()) { perform = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } if (perform) { using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(Core)) { _errormessage = ""; await Task.Run(() => { this.threadMethod(); }); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } } } result = true; } return result; }