您可以将代理人传递给您的get
方法。试试这个:
function Get(string ServerIP, string, remotefilename, string clientfilename, Action<YourResponseType> Applications_callback_function)
{
// your logic...
Applications_callback_function(data_from_request);
}
或者,如果反应是单一类型的不是:
function Get<T>(string ServerIP, string remotefilename, string clientfilename, Action<T> Applications_callback_function)
{
// your logic...
Applications_callback_function(data_from_request);
}
// caller...
Get<ResponseType>("127.0.0.1", "foo.txt", "bar.txt", myHandler);
function myHandler(ResponseType data)
{
// handle response...
}
您使用委托回调参数可以做到这一点。假设库是用C#编写的... –