Reputation: 397
I hope you can help me with the following:
I have a WebService method which is supposed to return an array of CompensationPlanReturnReturn objects. The method is called like this:
//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";
}
Upvotes: 1
Views: 1105
Reputation: 81233
Async methods breakdown into two submethods - Begin
and End
.
You need to call EndCompensationPlan_Out_Sync
to get the actual result returned by method -
private void complete(IAsyncResult result)
{
var actualResult = test.EndCompensationPlan_Out_Sync(result);
lblStatus.Text = "Complete";
}
Upvotes: 2
Reputation: 887215
You need to call test.EndCompensationPlan_Out_Sync(result)
, which will return the result of the asynchronous operation, or throw an exception if an error occurred.
Upvotes: 4
Reputation: 21088
Try to use the AsyncState-Property and cast it the the given Type.
Like this:
cSACommand = (SACommand)Result.AsyncState;
Upvotes: 0