Exemplo n.º 1
0
        /// <see cref="IDisposable.Dispose"/>
        public void Dispose()
        {
            if (this.dssThread != RCThread.CurrentThread)
            {
                throw new DssException("AlarmClockManager.Dispose must be called from the DSS-thread!");
            }

            /// Stop and dispose every unused timer.
            int numOfTimers = this.timers.Length;

            for (int i = 0; i < numOfTimers; i++)
            {
                AlarmClockThread timer = this.timers.Get();
                TraceManager.WriteAllTrace(string.Format("Get timer - {0}", this.timers.Length), DssTraceFilters.ALARM_CLOCK_MANAGER_INFO);
                timer.Stop();
                timer.Dispose();
                this.timers.Push(timer);
                TraceManager.WriteAllTrace(string.Format("Push timer - {0}", this.timers.Length), DssTraceFilters.ALARM_CLOCK_MANAGER_INFO);
            }

            /// Stop and dispose every timer that are currently in use.
            foreach (KeyValuePair <AlarmClockThread, AlarmClock> item in this.alarmClocks)
            {
                AlarmClockThread timer = item.Key;
                timer.Stop();
                timer.Dispose();
            }
        }
Exemplo n.º 2
0
        /// <see cref="IAlarmClockInvoke.CancelAlarmClock"/>
        public void CancelAlarmClock(AlarmClock whichClock)
        {
            if (this.dssThread != RCThread.CurrentThread)
            {
                throw new DssException("AlarmClockManager.CancelAlarmClock must be called from the DSS-thread!");
            }

            lock (this.lockObj)
            {
                if (this.clockTimerMap.ContainsKey(whichClock))
                {
                    AlarmClockThread correspondingTimer = this.clockTimerMap[whichClock];
                    correspondingTimer.Stop();
                }
                else
                {
                    TraceManager.WriteAllTrace("Warning! Invalid alarm clock cancel!", DssTraceFilters.ALARM_CLOCK_MANAGER_INFO);
                }
            }
        }