Пример #1
0
        private void ReadData_Click(object sender, RoutedEventArgs e)
        {
            var client = new ComponentManagerClient();

            Task.Run(() => {
                var data = client.ReadData();
                // TODO show read data
            });
        }
Пример #2
0
        //Comments about the exercise: Use async/await if possible
        private async void  ReadData_Click(object sender, RoutedEventArgs e)
        {
            ShowData.ItemsSource = null;

            IComponentManager cm = new ComponentManagerClient();

            // Comments about the exercise: Dot not block GUI while communicating to the service, it should be responsive all the time.
            // Use async/await if possible
            IEnumerable <PersonalData> list = await Task.Run <IEnumerable <PersonalData> >(() => cm.ReadDataAsync());

            this.UpdateLayout();

            //perform a synchronous, rather than asynchronous. Tip: remove async modifier
            //IEnumerable<PersonalData> list = cm.ReadData();

            // Comments about the exercise: Show LastName and FirstName on ListView, ordered by LastName and only persons older than 16 years old.
            // Use LINQ when possible.
            var itemList = (from item in list
                            where item.Age > 16
                            orderby item.LastName, item.FirstName
                            select item);

            ShowData.ItemsSource = itemList;
        }