Asynchronous Web and Network Calls on the Client in WPF(摘录)

1. Solution:WebApp, WpfAff

2. WebApp add :  Silverlight-enabled WCF Service

[OperationContract]
        public IList<Customer> GetCustomers()
        {
            List<Customer> results = new List<Customer>();
            results.Add(new Customer {LastName="Brown",FisrtName="Pete" });
            results.Add(new Customer { LastName = "Stagner", FisrtName = "Joe" });
            results.Add(new Customer { LastName = "Liberty", FisrtName = "Jesse" });
            results.Add(new Customer { LastName = "Galloway", FisrtName = "Jon`" });
            return results;
        }

3. WpfApp:

       private void CallService_Click(object sender, RoutedEventArgs e)
        {
            var client = new Service.CustomerServiceClient();
            client.GetCustomersCompleted += (s, ev) =>
            {
                CustomerList.ItemsSource = ev.Result;
            };
            client.GetCustomersAsync();
        }

---------------------------------------------------

                   <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding LastName}" />
                        <TextBlock Text=", " />
                        <TextBlock  Text="{Binding FisrtName}"/>
                    </StackPanel>
                </DataTemplate>

Solution:

WpfAsynCall

 

你可能感兴趣的:(NetWork)