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

时间:2018-01-24 08:06:28

标签: c# android xamarin

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

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();
    }

1 个答案:

答案 0 :(得分:0)

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

或者您可以添加try-catch以获取错误消息。

在您的代码中,此行

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

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

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