0

我正在使用 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;
        }
    }

我想从 GetCustomersHandler 类返回响应到被调用的类,我在 Form1 类的 netConnection.Call 中调用了 GetCustomersHandler,我想从 GetCustomersHandler 返回/获取响应(对象结果)到 Form1。

4

1 回答 1

1

让您的回调对象将结果存储为属性。

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; }
}

在调用函数中,保留您的回调对象。然后当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;
于 2013-05-24T20:03:09.627 回答