public async void Initialize() { TaihaToolkit.RegisterComponents(WPFComponent.Instance); TelemetryClient.TrackEvent("PluginLoaded"); // Set a hook to detect app crash try { var app = LocalizationUtil.GetApplication(); app.DispatcherUnhandledException += App_DispatcherUnhandledException; } catch (Exception ex) { TelemetryClient.TrackException("Failed to set set a hook to detect app crash.", ex); } // Obtain default app culture try { ResourceHolder.Instance.Culture = LocalizationUtil.GetCurrentAppCulture(); UpdateChineseCulture(); } catch (Exception ex) { TelemetryClient.TrackException("Failed to get default app culture.", ex); } // Initialize KCVDB client try { var sessionId = Guid.NewGuid().ToString(); apiSender_ = new ApiSender(sessionId); viewModel_ = new ToolViewViewModel( apiSender_.KcvdbClient, sessionId, new WPFDispatcher(Dispatcher.CurrentDispatcher)); } catch (Exception ex) { TelemetryClient.TrackException("Failed to initialize KCVDB client.", ex); } Settings.Default.PropertyChanged += Settings_PropertyChanged; TelemetryClient.TrackEvent("PluginInitialized"); try { await CheckForUpdate(); } catch (Exception ex) { TelemetryClient.TrackException("Failed to check the latest version.", ex); if (ex.IsCritical()) { throw; } } }