gpt4 book ai didi

c# - 如何使用 AsyncCallback 获取方法结果?

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

我希望你能在以下方面帮助我:

我有一个 WebService 方法,它应该返回一个 CompensationPlanReturnReturn 对象数组。该方法是这样调用的:

//This is the object I need to instanciate  because it contains the method I wanna call
CompensationPlan_Out_SyncService test = new CompensationPlan_Out_SyncService();
//This is the method that is supposed to return me an array of CompensationPlanReturnReturn objects
//The data.ToArray() is the parameter the method need, then I pass the method that I wanna run when the method finishes and I dont know what to pass as the final parameter
test.BeginCompensationPlan_Out_Sync(data.ToArray(), new AsyncCallback(complete), null)

//The method description is:
public System.IAsyncResult BeginCompensationPlan_Out_Sync(CompensationPlanDataCompensationPlan[] CompensationPlanRequest, System.AsyncCallback callback, object asyncState)

//On this method I'd like to access to the resuls (the array of CompensationPlanReturnReturn) but I dont know how
private void complete(IAsyncResult result)
{
lblStatus.Text = "Complete";
}

最佳答案

需要调用test.EndCompensationPlan_Out_Sync(result),返回异步操作的结果,如果出错则抛出异常。

关于c# - 如何使用 AsyncCallback 获取方法结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18255312/

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