繁体   English   中英

在通用应用程序中调用 WCF 服务

[英]calling WCF service in a Universal application

我正在尝试在 Windows 通用应用程序中调用 WCF 服务,显然您只能异步调用函数“GetMoments”。 但是我无法填充 ObservableCollection。

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();

moment.Wait() 只是永远等待并且不允许调用 moment.Start(),这会引发异常。 我怎样才能填满收藏?

你能用等待/异步模式测试吗? 例如:

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();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM