获得回调结果

时间:2017-05-06 01:09:08

标签: c# callback asynccallback

我正在用委托和回调编写一个C#异步库来防止阻塞。我也在使用第三方库,它使用相同的回调方法。

如何从第三方侦听器获取状态到我的回调?

代码:

public class myController
{
    private ThirdPartyController thirdPartyController ;
    public delegate void ConnectedDelegate(string status);

    public myController()
    {
        thirdPartyController = ThirdPartyController .getInstance(new MyControllerListener());
    }

    public void Connect(ConnectedDelegate callback)
    {
        3PartyController.start();
        callback(<<Connectedstatus>>); // <= How to get status from onConnected? 
    }
}

public class MyControllerListener: ThirdPartyControllerListener
{
    public void onConnected(ConnnectedStatus status)
    {
        // Want status from here.
    }
}

0 个答案:

没有答案