我正在使用WCF开发一个Silverlight项目。我需要在另一个WCF函数完成后从WCF调用一个函数。这是我的代码:
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();
我该怎么做?
答案 0 :(得分:1)
在obj.Delete Person Async(id)函数的回调中调用函数“GetPersonListAsync”。代码将如下所示:
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();
}