Example #1
0
        protected override void OnInitialize()
        {
            base.OnInitialize();
            DisplayName = Strings.RevisionsViewModel_DisplayName;

            var loadingTask = Task.Run(async delegate
            {
                try
                {
                    var revisions = await _productServiceModel.GetProducts(new ProductQuery
                    {
                        Identifier     = Product.Identifier,
                        RevisionFilter = RevisionFilter.All
                    }).ConfigureAwait(false);

                    var vms = revisions.Select(r => new ProductInfoViewModel(r)).ToArray();
                    await Execute.OnUIThreadAsync(() => Revisions.AddRange(vms));
                }
                catch (Exception e)
                {
                    await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message);
                }

                finally
                {
                    await Execute.OnUIThreadAsync(CommandManager.InvalidateRequerySuggested);
                }
            });

            TaskNotifier = new TaskNotifier(loadingTask);
        }