如何调用以下方法手册?
private void NetworkResponseReceived(object sender, Network.ResponseReceivedEventArgs e)
{
ExecuteTask();
}
有类似的东西:
NetworkResponseReceived();
需要在括号中插入什么内容?
答案 0 :(得分:13)
显然你可以这样称呼它
NetworkResponseReceived(null, new ResponseReceivedEventArgs());
但这可能是谎言。 Handler期望收到响应(来自某个对象),但事实并非如此。我认为最好将处理程序的逻辑提取到单独的方法中。并从您的代码和处理程序中调用该方法。像这样:
void NetworkResponseReceived(object sender, Network.ResponseReceivedEventArgs e)
{
// this method can have some arguments, if needed
DoSomethingBusinessRelated();
}
简单地从其他地方调用相同的方法:
DoSomethingBusinessRelated();
答案 1 :(得分:3)
这应该有效:
NetworkResponseReceived(null, new Network.ResponseReceivedEventArgs());
答案 2 :(得分:2)
试试这个;
NetworkResponseReceived(null, new ResponseReceivedEventArgs());