如何在c#中正确调用处理程序方法

本文关键字:调用 处理 程序 方法 | 更新日期: 2023-09-27 17:54:07

我有以下方法的问题-GetTransactionsCompletedEventHandler。我正试图向它传递必要的参数,但它也要求以我不熟悉的格式提供更多参数。

请求GetTransactionsCompletedEventHandler(object[] results(object, GetTransactionsCompletedEventArgs)target)

谁能指出我在正确的方向如何正确地调用这个方法?

static object[] results;
static Exception exception;
static bool cancelled;
static object userState;
TransactionService.GetTransactionsCompletedEventArgs test1 = new TransactionService.GetTransactionsCompletedEventArgs(results, exception, cancelled, userState);
public void testMethod()
{
}
static List<string> orderlist;
public object testObject;
public void getTransactions()
{
    TransactionService.GetTransactionsCompletedEventHandler test = new TransactionService.GetTransactionsCompletedEventHandler(testObject, test1);
}

如何在c#中正确调用处理程序方法

感谢您的宝贵意见。我发现我这样做是不正确的,应该只是实例化一个服务,并且可以通过这种方式获得事务。

TransactionService.TransactionService _service = new TransactionService.TransactionService();
TransactionService.TransactionSearchParameters _params = new TransactionService.TransactionSearchParameters();
TransactionService.Transaction []list = _service.GetTransactions(_params);