为什么事件不等待回调完成?

时间:2016-06-21 12:00:44

标签: c# xamarin

我无法获得以下事件来等待ActionShared.BL.Managers.TaskManager.GetTask的结果 - 它只是继续 - 并且从不显示TaskDetailsPageViewController。如果你能看到错误,请提供建议吗?

public async void OnButtonPressedTask (object sender, CellUtilityButtonClickedEventArgs e)
{
    if(e.UtilityButtonIndex == 1){
        // Edit
        var a =  GetItem(e.IndexPath) as Outstanding;
        APTask  ab = new APTask();
        ab.Id = Convert.ToInt32(a.Entity.Id);
        await ActionShared.BL.Managers.TaskManager.GetTask  (ab.Id, async (response) => {
                var taskDetailsPage = new TaskDetailsPageViewController(response, e.IndexPath);
                parent.NavigationController.PushViewController(taskDetailsPage, true);  
        });

    }
}

1 个答案:

答案 0 :(得分:0)

谢谢你们 我更改了ActionShared.BL.Managers.TaskManager.GetTask以使用async / await而不是回调。