/// <summary> /// Event handler for MQTT massage received /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MQTTManager_MessageReceived(object sender, SensorEventArgs e) { decimal temp = e.Temperature; decimal hum = e.Humidity; Console.WriteLine("Temperature: {0}C, Humidity: {1}%", temp, hum); txtTemperature.Dispatcher.BeginInvoke((Action)(() => txtTemperature.Text = "Temperature: " + e.Temperature + "°C")); txtHumidity.Dispatcher.BeginInvoke((Action)(() => txtHumidity.Text = "Humidity: " + e.Humidity + "%")); guageHumidity.Dispatcher.BeginInvoke((Action)(() => guageHumidity.Value = (double)e.Humidity)); guageTemperature.Dispatcher.BeginInvoke((Action)(() => guageTemperature.Value = (double)e.Temperature)); }
protected void OnMessageReceived(SensorEventArgs args) { MessageReceived?.BeginInvoke(this, args, null, null); }