如何调用change resetButton.Clicked + = async(sender,e)=> {}调用方法?

时间:2017-07-19 02:20:52

标签: c#

我有这个代码,我缩短了这个问题:

resetButton.Clicked += async (sender, e) =>
{
   var response = await X.DisplayAlert("X","Y","Yes", "No");
};

我想将其分解为一种方法,所以我尝试了这个:

resetButton.Clicked += resetButtonClicked;

protected void resetButtonClicked(object sender, EventArgs e)
{
   var response = await X.DisplayAlert("X","Y","Yes", "No");
}

但这不起作用,因为我需要指定方法为异步。有人可以给我一些建议吗?

1 个答案:

答案 0 :(得分:1)

这项工作。

resetButton.Clicked += resetButtonClicked;

protected async Task resetButtonClicked(object sender, EventArgs e)
{
   var response = await X.DisplayAlert("X","Y","Yes", "No");
}