gpt4 book ai didi

c# - 您的应用程序已进入中断状态,但没有代码可显示,因为所有线程都在 xamarin android 中执行外部代码

转载 作者:太空宇宙 更新时间:2023-11-03 14:57:12 24 4
gpt4 key购买 nike

这是我在 xamarin android 中的一段代码,当 Vs 2017 想要执行“await Task.Delay(200);”行时,会出现标题中提到的错误,请知道的告诉我

private async void _btnanswer2_Click(object sender, EventArgs e)
{
if(Ans == 2)
{
_btnanswer2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#006400"));
mScore = mScore + 1;
_txtscore.Text = "امتیاز: " + mScore.ToString();
}
else
{
_btnanswer2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FF0000"));
}
await Task.Delay(200); //Error after Execute this line
_btnanswer2.SetBackgroundColor(Android.Graphics.Color.ParseColor("0091EA"));
bandeira++;
RefreshQue();
}

最佳答案

You can refer to this link ,就像@atik sarker 所说的那样。

或者你可以添加try-catch来获取错误信息。


在你的代码中,这一行

btnaanswer2.SetBackgroundColor(Android.Graphics.Color.ParseColor("0091EA"));

它将抛出 Java.Lang.IllegalArgumentException: Unknown color

因此您需要添加#,请将其替换为btnanswer2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#0091EA"));

关于c# - 您的应用程序已进入中断状态,但没有代码可显示,因为所有线程都在 xamarin android 中执行外部代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48417539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com