我想将回调方法作为参数传递给广义方法,但无法弄清楚如何执行它。我试过Func<IAsyncResult>
,但它似乎并不兼容。回调的传递回调方法作为参数
public void webRequest(string apiName, string requestMethod, string requestData, Func<IAsyncResult> callback)
{
...
request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
}
签名是:
void GetRequestStreamCallback(IAsyncResult asyncResult)
不要说“不行”。告诉我们你的期望,以及实际发生的情况。 –