0

我使用以下代码作为使用服务参考:

var myService = new MyService.MyServiceClient();
myService.DeleteOCDFCompleted += MyServiceDeleteOCDFComplete;
myService.DeleteOCDF(OCDF.OcdfId);

void MyServiceDeleteOCDFComplete(object sender, MyService.DeleteOCDFCompletedEventArgs e)
{
//  OCDFList.Remote(**ocdf that deleted**);
  MessageBox.Show("Delete Completed successfully.");
}

我想从我的列表中删除已删除的对象,但如何确定MyServiceDeleteOCDFComplete函数中的已删除参数。

换句话说:如何向服务参考事件发送额外的参数。

提前致谢。

4

1 回答 1

3

您可以使用该DeleteOCDF方法的附加参数(称为userState)。该参数可以是任何对象,并将在其UserState属性中传递给事件处理程序。

var myService = new MyService.MyServiceClient();
myService.DeleteOCDFCompleted += MyServiceDeleteOCDFComplete;
myService.DeleteOCDF(OCDF.OcdfId, OCDF.OcdfId);

void MyServiceDeleteOCDFComplete(object sender, MyService.DeleteOCDFCompletedEventArgs e)
{
    int ocdfId = (int)e.UserState;
    MessageBox.Show("Delete Completed successfully.");
}
于 2013-05-12T15:17:34.230 回答