我创建了控制台应用程序,它为Mqtt Broker订阅了多个主题。每当有关于订阅主题的新数据时,我已经注册了MqttMsgPublishedReceived
甚至哪个triger。该应用程序正在为单个订阅正常运行。但是当我尝试运行多个订阅时,应用程序正在关闭。如何使MqttMsgPublisheReceived
事件处理多个发布。以下是我的代码段。
for(int i=0;i<client.Length;i++)
{
subscribe(hostname,port,clientid);
}
public void subscribe()
{
//initialize client
client.MqttMsgPublishReceived+=client_MqttMsgPublishReceived
}
public void client_MqttPublishReceived(object sender,MqttMsgPublishEventargs e)
{
//business logic
}
MqttMsgPublishReceived
事件因同步消息而崩溃。提前致谢