2010-10-20 74 views
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

不能從發送完成回調,因爲它的簽名是由SendAsync參數委託(EventHandler<SendCompletedEventArgs>)定義返回的變量。你可以做的是調用其他一些方法來傳遞異步操作結果,你可以在e參數中找到它。

+0

我認爲你是對的,謝謝。 – Pratik 2010-10-20 13:05:10