我想將回調方法作爲參數傳遞給廣義方法,但無法弄清楚如何執行它。我試過Func<IAsyncResult>
,但它似乎並不兼容。回調的傳遞迴調方法作爲參數
public void webRequest(string apiName, string requestMethod, string requestData, Func<IAsyncResult> callback)
{
...
request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
}
簽名是:
void GetRequestStreamCallback(IAsyncResult asyncResult)
不要說「不行」。告訴我們你的期望,以及實際發生的情況。 –