protected override async void OnAppearing() { base.OnAppearing(); // don't show any content until we're authenticated if (_AuthenticationService.IsAuthenticated) { Content.IsVisible = true; if (!_SalesDashboardChartViewModel.IsInitialized) { await _SalesDashboardChartViewModel.ExecuteLoadSeedDataCommand(); _SalesDashboardChartViewModel.IsInitialized = true; } if (!_SalesDashboardLeadsViewModel.IsInitialized) { await _SalesDashboardLeadsViewModel.ExecuteLoadSeedDataCommand(); _SalesDashboardLeadsViewModel.IsInitialized = true; } } else { Content.IsVisible = false; } }
protected override async void OnAppearing() { base.OnAppearing(); // don't show any content until we're authenticated Content.IsVisible = false; if (_AuthenticationService.IsAuthenticated) { Content.IsVisible = true; List <Task> tasksToRun = new List <Task>() { Task.Factory.StartNew(async() => { if (!_SalesDashboardChartViewModel.IsInitialized) { await _SalesDashboardChartViewModel.ExecuteLoadSeedDataCommand(); _SalesDashboardChartViewModel.IsInitialized = true; } }), Task.Factory.StartNew(async() => { if (!_SalesDashboardLeadsViewModel.IsInitialized) { await _SalesDashboardLeadsViewModel.ExecuteLoadSeedDataCommand(); _SalesDashboardLeadsViewModel.IsInitialized = true; } }) }; // Awaiting these parallel task allows the leadsView and salesChartView to load independently. // Task.WhenAll() is your friend in cases like these, where you want to load from two different data models on a single page. await Task.WhenAll(tasksToRun.ToArray()); Insights.Track("Dashboard Page"); } _SalesDashboardLeadsViewModel.ExecuteLoadLeadsCommand(); }