异步WCF服务,如何返回任何变量

时间:2010-10-20 12:33:18

标签: silverlight-4.0

public int SendServiceCallFromAnotherClass()
{
   client.SendCompleted += new EventHandler<SendCompletedEventArgs>(client_SendCompleted);

   client.SendAsync(clientSettings);

   //i have to return some int here from my service
}

void client_SendCompleted(object sender, SendCompletedEventArgs e)
{
   //so here i have to return int variable from my SendServiceCallFromAnotherClass method
}

1 个答案:

答案 0 :(得分:1)

您无法从发送完成的回调中返回变量,因为其签名由SendAsync参数委托(EventHandler<SendCompletedEventArgs>)定义。您可以做的是调用一些其他方法传递您在e参数中找到的异步操作结果。