如何手动触发正在用作事件的方法ElapsedEventArgs
// this run every X minutes
int periodMilliSeconds = periodMinutes * 60000;
timerStatus = new System.Timers.Timer(periodMilliSeconds);
timerStatus.Elapsed += new ElapsedEventHandler(OnTimerStatus);
// But I need to run this method at user interaction even Elapsed has not being fired
// Method to call pro grammatically not from the Timer
private static void OnTimerStatus(object source, ElapsedEventArgs e)
{
}
答案 0 :(得分:1)
如果您不需要,可以使用空参数调用方法。
// Somewhere else
OnTimerStatus(null, null);