private async void OnLoadBrickViewAction() { var actions = ServiceLocator.ActionTemplateService.GetActionTemplatesForCategry(_selectedBrickCategory); BrickCollection = new BrickCollection(); var actionsToLoadAsync = new BrickCollection(); var actionsToLoadImmediately = new BrickCollection(); var count = 0; foreach (var action in actions) { if (count <= 6) { actionsToLoadImmediately.Add(action); } else { actionsToLoadAsync.Add(action); } count++; } await Task.Run(() => ServiceLocator.DispatcherService.RunOnMainThread(() => { foreach (var action in actionsToLoadImmediately) { BrickCollection.Add(action); } })); foreach (var action in actionsToLoadAsync) { await Task.Run(() => ServiceLocator.DispatcherService.RunOnMainThread(() => BrickCollection.Add(action))); } }
private async void OnLoadBrickViewAction() { var actions = ServiceLocator.ActionTemplateService.GetActionTemplatesForCategry(_selectedBrickCategory); BrickCollection = new BrickCollection(); var actionsToLoadAsync = new BrickCollection(); var actionsToLoadImmediately = new BrickCollection(); var count = 0; foreach (var action in actions) { if (count <= 6) actionsToLoadImmediately.Add(action); else actionsToLoadAsync.Add(action); count++; } await Task.Run(() => ServiceLocator.DispatcherService.RunOnMainThread(() => { foreach (var action in actionsToLoadImmediately) { BrickCollection.Add(action); } })); foreach (var action in actionsToLoadAsync) { await Task.Run(() => ServiceLocator.DispatcherService.RunOnMainThread(() => BrickCollection.Add(action))); } }