示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (timer != null)
     {
         timer.Stop();
         mqtt.Dispose();
         mqtt  = null;
         timer = null;
     }
 }
示例#2
0
        private void Init()
        {
            mqtt = new MqttConnector("<device id>",
                                     "<password>",
                                     "<iot hub name>");
            mqtt.OnC2DReceived += Mqtt_OnC2DReceived;

            random         = new Random((int)DateTime.UtcNow.Ticks);
            timer          = new Timer();
            timer.Interval = 3000;
            timer.Tick    += Timer_Tick;
        }