我正在尝试使用多个接口实现 AllJoyn 消费者。AllJoyn 菜单为自省 xml 中的所有接口创建帮助文件。添加观察者事件处理程序并为所有接口启动相同的事件后,只有第一个观察者事件处理程序被触发并完成。
例如,在 LSF 内省中,我们有四个接口,因此:
AllJoynBusAttachment bus_Consumer = new AlljoynBusAttachment();
watcher_Consumer = new LampStateWatcher(bus_Consumer);
watcher_Consumer.Added += Watcher_Consumer_Added;
watcher_Consumer.Start();
watcher_Details = new LampDetailsWatcher(bus_Consumer);
watcher_Details.Added += Watcher_Details_Added;
watcher_Details.Start();
private async void Watcher_Details_Added(LampDetailsWatcher sender, AllJoynServiceInfo args)
{
Join_Session_Details = await LampDetailsConsumer.JoinSessionAsync(args, sender);
Consumer_Details = Join_Session_Details.Consumer;
if (Join_Session_Details.Status == AllJoynStatus.Ok)
{
var LampName = await Consumer_Details.GetLampIDAsync();
Status_List.Items.Add(LampName.LampID);
}
}
private async void Watcher_Consumer_Added(LampStateWatcher sender, AllJoynServiceInfo args)
{
Join_Session = await LampStateConsumer.JoinSessionAsync(args, sender);
Consumer_Bulb = Join_Session.Consumer;
if (Join_Session.Status == AllJoynStatus.Ok)
{
LightBulbs.Add(Consumer_Bulb);
}
Consumer_Bulb.SessionMemberRemoved += Consumer_Bulb_SessionMemberRemoved;
}
在这种情况下,只有Watcher_Consumer_Added
被触发并完成,而Watcher_Details_Added
被触发但未完成。
我怎样才能完成这两个过程。上述方法在消费者上实现多个接口是否正确?
PS:这是使用在 Windows10 上运行的 VS2015 的 AllJoyn Studio 扩展