【问题标题】:Silverlight Web ServiceSilverlight 网络服务
【发布时间】:2010-08-04 04:38:53
【问题描述】:

下面是我在 SilverLight 中使用 web servcie 的代码。

private void button1_Click(object sender, RoutedEventArgs e)
{
      BasicHttpBinding bind = new BasicHttpBinding();
      EndpointAddress endpoint = new EndpointAddress("http://loalhost/Service.asmx");
      ServiceSoapClient client = new ServiceSoapClient(bind, endpoint);
      client.RunHelloCompleted += new EventHandler<RunHelloCompletedEventArgs>(client_RunQwinCompleted);
      client.RunHelloAsync(command);
 }

 void client_RunHelloCompleted(object sender, RunHelloCompletedEventArgs e)
 {
      txtProcess.Text=Process(e.Result);
 }

我想知道一种方法,在我运行 RunHelloAsync(Command) 之后,我想获得返回的结果而不去 Completed 事件。请给我提意见。谢谢。

【问题讨论】:

  • 为什么你不能在完成的活动中做你需要的?

标签: silverlight silverlight-3.0


【解决方案1】:

简单的答案:你不能。 Silverlight 中的所有内容都是异步的,因此无法在 client.RunHelloAsync(command) 调用后阻塞并等待结果。

长答案:有一些方法可以模拟以同步方式处理调用,但调用仍然是异步进行的。查看this thread 以获得更多答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-16
    • 2011-09-15
    • 2011-01-09
    • 2018-02-05
    • 2015-02-11
    相关资源
    最近更新 更多