我正在用委托和回调编写一个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.
}
}