我有這個例外,但我一直難以解決它。如果有人可以幫助我,我會非常高興。我的目標是在 xamarin的標簽欄位中顯示我收到的訊息(來自代理) 。但不幸的是,它在 atm 中不起作用。
private async void onMessageReceived(MqttApplicationMessage msg) //async hinzugefügt
{
string msgEncoded = (Encoding.UTF8.GetString(msg.Payload));
double x = double.Parse(msgEncoded);
Console.WriteLine(msgEncoded);
x = Convert.ToDouble(tempWert.Text);
tempWert.Text = x.ToString();
//überprüfung, ob Maschine zu warm
if (x >= 40)
{
await Task.Delay(5000);
Noti();
}
else
{
Console.WriteLine("Die Temperatur ist geringer als 40");
}
}
uj5u.com熱心網友回復:
使用主執行緒
MainThread.BeginInvokeOnMainThread(() =>
{
// Code to run on the main thread
tempWert.Text = x.ToString();
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/513547.html
標籤:xmlxamarinxamarin.formsxamarin.android
