Reputation: 616
I am developing a Silverlight project using WCF.I need to call a function from WCF after another WCF function has finished.Here is my code :
Int32 id = Convert.ToInt32(((TextBlock)dataGrid1.Columns[0].GetCellContent(dataGrid1.SelectedItem)).Text.ToString());
Service1Client obj = new Service1Client();
obj.DeletePersonAsync(id);
//Wait for delete operation
obj.GetPersonListCompleted += new EventHandler<GetPersonListCompletedEventArgs>(ListPeople);
obj.GetPersonListAsync();
How can i do that?
Upvotes: 1
Views: 140
Reputation: 3462
Call the function "GetPersonListAsync" int the callback of obj.DeletePersonAsync(id) function. The code will be soemthing like as follows:
private void somefunction()
{
Int32 id = Convert.ToInt32(((TextBlock)dataGrid1.Columns[0].GetCellContent(dataGrid1.SelectedItem)).Text.ToString());
Service1Client obj = new Service1Client();
obj.DeletePersonAsyncCompleted += new EventHandler<DeletePersonCompletedEventArgs>(PersonDeleted);
obj.DeletePersonAsync(id);
}
private void PersonDeleted(DeletePersonCompletedEventArgs serviceResponse)
{
//Wait for delete operation
obj.GetPersonListCompleted += new EventHandler<GetPersonListCompletedEventArgs>(ListPeople);
obj.GetPersonListAsync();
}
Upvotes: 1