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