您可以将委托传递给您的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...
}