private void button1_Click(object sender, EventArgs e) { if (timer != null) { timer.Stop(); mqtt.Dispose(); mqtt = null; timer = null; } }
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; }