Channel9Downloader.ViewModels.Categories.CategoriesVM.InitializeCategoriesAsync C# (CSharp) Method

InitializeCategoriesAsync() private method

Initializes categories in the background.
private InitializeCategoriesAsync ( TaskScheduler continuationTaskScheduler ) : void
continuationTaskScheduler System.Threading.Tasks.TaskScheduler The task scheduler that should be used for the continuation. /// This should usually be the scheduler of the UI thread.
return void
        private void InitializeCategoriesAsync(TaskScheduler continuationTaskScheduler)
        {
            IsAdornerVisible = true;
            Entities.Categories categories = null;
            var task = new Task(() =>
                {
                    categories = _categoryRepository.GetCategories();
                });

            task.ContinueWith(
                x =>
                    {
                        _seriesSelectionVM = _dependencyComposer.GetExportedValue<ISeriesSelectionVM>();
                        _seriesSelectionVM.Initialize(categories.Series, TextFilter);

                        _showSelectionVM = _dependencyComposer.GetExportedValue<IShowSelectionVM>();
                        _showSelectionVM.Initialize(categories.Shows, TextFilter);

                        _tagSelectionVM = _dependencyComposer.GetExportedValue<ITagSelectionVM>();
                        _tagSelectionVM.Initialize(categories.Tags, TextFilter);

                        CurrentContent = _tagSelectionVM;

                        IsAdornerVisible = false;
                        CommandManager.InvalidateRequerySuggested();
                    },
                continuationTaskScheduler);

            task.Start();
        }