public override void Initialize() { if (!_dataLoaded) { IsBusyLoading = true; var compositionsTask = Task.Factory.StartNew(() => _providerFactory.CompositionsProvider.GetCompositionsAsync().Result) .ContinueWith(t => t.Result.Select(x => x.ToCheckable()).CopyTo(Compositions), TaskScheduler.FromCurrentSynchronizationContext()); var templatesTask = Task.Factory.StartNew(() => _providerFactory.TemplateProvider.GetTemplatesAsync().Result) .ContinueWith(t => { t.Result.CopyTo(Templates); }, TaskScheduler.FromCurrentSynchronizationContext()); Task.WhenAll(compositionsTask, templatesTask) .ContinueWith(result => { IsBusyLoading = false; _dataLoaded = true; }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } if (_updatedComposition == null || _updatedComposition.State == ItemState.Unchanged) { return; } if (!Compositions.Contains(_updatedComposition)) { Compositions.Add(_updatedComposition); } CheckItem(); _updatedComposition = null; }
public bool Contains(INonTerminalDescriptor descriptor) { return(Compositions.Contains(descriptor)); }