[英]C# return an a class
I'm using FluorineFx to send/receive AMF3 data over server. 我正在使用FluorineFx通过服务器发送/接收AMF3数据。
netConnection.Call("my-amf", "zend", "Ka_Services_Park", "getCompleteParkOfUser", new GetCustomersHandler(), new object[] { "msg_2580671638", "20251876" });
public class GetCustomersHandler : IPendingServiceCallback
{
public void ResultReceived(IPendingServiceCall call)
{
object result = call.Result;
}
}
i want to return response from class GetCustomersHandler to class from was called i called GetCustomersHandler in netConnection.Call in Form1 class, i want to return/get response (object result) from GetCustomersHandler to Form1. 我想将响应从类GetCustomersHandler返回到类,我称之为Form1类的netConnection.Call中的GetCustomersHandler,我想将响应(对象结果)从GetCustomersHandler返回/获取到Form1。
Have your callback object store the result as a property. 让您的回调对象将结果存储为属性。
public class GetCustomersHandler : IPendingServiceCallback
{
GetCustomersHandler()
{
this.Signal = new ManualResetEvent(false);
}
public void ResultReceived(IPendingServiceCall call)
{
this.Result = call.Result;
this.Signal.Set();
}
public ManualResetEvent Signal { get; protected set; }
public object Result { get; protected set; }
}
In the calling function, hold on to your callback object. 在调用函数中,保留您的回调对象。 Then when netConnection.Call()
returns, you can retrieve the value 然后当netConnection.Call()
返回时,您可以检索该值
GetCustomersHandler callback = new GetCustomersHandler();
netConnection.Call("my-amf", "zend", "Ka_Services_Park", "getCompleteParkOfUser", callback, new object[] { "msg_2580671638", "20251876" });
callback.WaitOne();
object result = callback.Result;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.