Serve Laurijssen
Serve Laurijssen

Reputation: 9733

calling WCF service in a Universal application

I am trying to call a WCF service in a windows universal application and apparently you can only call the function "GetMoments" asynchronously. But I can't get the ObservableCollection filled.

EndpointAddress address = new EndpointAddress("net.tcp://localhost:9999/DeliveryService");

NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

DeliveryClient client = new DeliveryClient(binding, address);

Task<ObservableCollection<DeliveryMoment>> moments = client.GetMomentsAsync();

moments.Wait() just waits forever and calling moments.Start() is not allowed, this throws an exception. How can I get the collection filled?

Upvotes: 1

Views: 532

Answers (1)

Could you please test with await/async pattern ? For example:

public async void Load()
{
      EndpointAddress address = new EndpointAddress("net.tcp://localhost:9999/DeliveryService");

      NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

      DeliveryClient client = new DeliveryClient(binding, address);

      ObservableCollection<DeliveryMoment> moments = await client.GetMomentsAsync();
}

Upvotes: 1

Related Questions