static void Main(string[] args) { MQTTClientModule mqttclient = new MQTTClientModule(); try { //string topic = ConfigurationManager.AppSettings["topic"]; //var topicArr = topic.Split('|'); Task.Run(async() => { await mqttclient.ConnectMqttServerAsync(); //for (int i = 0; i < topicArr.Length; i++) //{ // await mqttclient.Subscribe(topicArr[i]); //} }); } catch (Exception ex) { Console.WriteLine("测试问题:" + ex.Message); Trace.WriteLine("测试问题:" + ex.Message); } Console.WriteLine("输入exit退出!"); while (true) { if (Console.ReadLine().ToLower() == "exit") { return; } } }