Silverlight 4.0 异步WCF服务,如何返回任何变量 public int SendServiceCallFromAnotherClass() { client.sendpleted+=新事件处理程序(client_sendpleted); client.sendaync(clientSettings); //我必须从我的服务中返回一些int } 无效客户端\u SendCompleted(对象发送方,SendCompletedEventArgs e) { //因此,这里我必须从SendServiceCallFromAnotherClass方法返回int变量 }

Silverlight 4.0 异步WCF服务,如何返回任何变量 public int SendServiceCallFromAnotherClass() { client.sendpleted+=新事件处理程序(client_sendpleted); client.sendaync(clientSettings); //我必须从我的服务中返回一些int } 无效客户端\u SendCompleted(对象发送方,SendCompletedEventArgs e) { //因此,这里我必须从SendServiceCallFromAnotherClass方法返回int变量 },silverlight-4.0,Silverlight 4.0,无法从发送完成回调返回变量,因为其签名是由sendsync参数委托(EventHandler)定义的。您可以调用其他方法来传递异步操作结果,该结果可以在e参数中找到 public int SendServiceCallFromAnotherClass() { client.SendCompleted += new EventHandler<SendCompletedEventArgs>(client_SendCompleted); client.SendAsync(cl

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

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
}