private async System.Threading.Tasks.Task InitOnUIThreadAsync() { Debug.Assert(ThreadHelper.CheckAccess(), "Expecting to be on the UI thread"); var logger = await this.GetMefServiceAsync <ILogger>(); // HACK: the telemetry manager has to be imported on the UI thread because // of a complicated chain of transitive dependencies: // TelemetryManager -> IActiveSolutionBoundTracker -> IBindingConfiguration -> IHost. // The host expects to be initialized on the UI thread. // The ui and non-ui parts of the host should be split into separate classes. try { logger.WriteLine(Resources.Strings.Telemetry_Initializing); telemetryManager = await this.GetMefServiceAsync <ITelemetryManager>(); logger.WriteLine(Resources.Strings.Telemetry_InitializationComplete); if (await IsSolutionFullyOpenedAsync()) { telemetryManager.Update(); } } catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex)) { // Suppress non-critical exceptions logger.WriteLine(Resources.Strings.Telemetry_ERROR, ex.Message); } }