2

如何调用以下方法手册?

  private void NetworkResponseReceived(object sender, Network.ResponseReceivedEventArgs e)
  {
         ExecuteTask();
  }

有类似的东西:

NetworkResponseReceived();

括号内需要插入什么?

4

3 回答 3

13

显然你可以这样称呼它

NetworkResponseReceived(null, new ResponseReceivedEventArgs());

但这将是谎言。处理程序期望收到响应(来自某个对象),这是不正确的。我认为最好将处理程序的逻辑提取到单独的方法中。并从您的代码和处理程序中调用该方法。像这样:

void NetworkResponseReceived(object sender, Network.ResponseReceivedEventArgs e)
{
    // this method can have some arguments, if needed
    DoSomethingBusinessRelated();
}

并简单地从其他地方调用相同的方法:

DoSomethingBusinessRelated();
于 2013-03-05T12:55:53.180 回答
3

这应该有效:

NetworkResponseReceived(null, new Network.ResponseReceivedEventArgs());
于 2013-03-05T12:56:06.540 回答
2

试试这样;

NetworkResponseReceived(null, new ResponseReceivedEventArgs());
于 2013-03-05T12:56:40.733 回答