public async void InitFeaturesAsync() { if (asyncInitStarted) { throw new InvalidOperationException("AsyncInitFeatures already triggered"); } asyncInitStarted = true; try { List <Tuple <Task, IFeature> > tasks = new List <Tuple <Task, IFeature> >(); foreach (var feature in Features) { tasks.Add(new Tuple <Task, IFeature>(feature.InitAsync(), feature)); } bool irrklangDependencyMissingHandled = false; foreach (var tuple in tasks) { try { await tuple.Item1; logger.Info(string.Format("Feature initialized: {0}", tuple.Item2.Name)); } catch (Exception exception) { if (!irrklangDependencyMissingHandled) { var validator = new IrrklangDependencyValidator(); irrklangDependencyMissingHandled = validator.HandleWhenMissingIrrklangDependency(exception); } logger.Error(exception, string.Format("Error at feature initialization: {0}", tuple.Item2.Name)); } } } catch (Exception exception) { logger.Error(exception, ""); } }
void HandleExceptions(Action action) { try { action(); } catch (LockFailedException) { try { AttemptToRestoreAlreadyRunningAppInstance(); } catch (Exception exception) { ShowErrorAsDialog(exception); } ShutdownCurrentApp(); } catch (ConfigCancelledException) { ShutdownCurrentApp(); } catch (Exception exception) { bool handled = false; var validator = new IrrklangDependencyValidator(); handled = validator.HandleWhenMissingIrrklangDependency(exception); if (!handled) { ShowErrorAsDialog(exception); } ShutdownCurrentApp(); } }