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

时间:2015-06-08 13:17:09

标签: c# methods parameters handler

我遇到以下方法的问题-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);
}

1 个答案:

答案 0 :(得分:0)

感谢您提供的有用评论。我发现我错误地解决了这个问题,应该只是实例化一个服务,并且能够以这种方式获得交易。

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