I have some timers stored in a Dictionary<string, Timer>. I could change that and store them differently if need be. The timers all call the same EventHandler to do things like remove objects from other dictionaries. But how can I tell which timer has elapsed and fired the EventHandler?
Code:Dictionary<string, System.Timers.Timer> currentAlertsTimers = new Dictionary<string, System.Timers.Timer>(); currentTimersList[currentKey].Elapsed += new ElapsedEventHandler(AlertHasExpired); currentTimersList[currentKey].Interval = waitTime.TotalMilliseconds; currentTimersList[currentKey].Enabled = true; public void AlertHasExpired(object source, ElapsedEventArgs e) { //delete the objects in the other dictionaries that have the same key and the timer that elapsed and fired this EventHandler }




Reply With Quote