收到多次发布后如何防止申请关闭?

时间:2018-06-08 10:40:16

标签: c# .net mqtt

我创建了控制台应用程序,它为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事件因同步消息而崩溃。提前致谢

0 个答案:

没有答案