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