Example #1
0
        private void SetTimer(Guid processId, TimeSpan interval, string name)
        {
            _lock.AcquireWriterLock(_lockTimeout);
            try
            {
                IDictionary <string, DateTime> processTimers;
                var key = new TimerKey {
                    ProcessId = processId, TimerName = name
                };

                if (Timers.ContainsKey(key))
                {
                    Timers[key] = DateTime.UtcNow.Add(interval);
                }
                else
                {
                    Timers.Add(key, DateTime.UtcNow.Add(interval));
                }

                if (NeedSave != null)
                {
                    NeedSave(this, EventArgs.Empty);
                }
            }
            finally
            {
                _lock.ReleaseWriterLock();
            }

            RefreshTimer();
        }
Example #2
0
        private void SetTimer(Guid processId, TimeSpan interval, string name)
        {
            _lock.AcquireWriterLock(_lockTimeout);
            try
            {
                IDictionary<string, DateTime> processTimers;
                var key = new TimerKey {ProcessId = processId, TimerName = name};

                if (Timers.ContainsKey(key))
                {
                    Timers[key] = DateTime.UtcNow.Add(interval);
                }
                else
                {
                    Timers.Add(key, DateTime.UtcNow.Add(interval));
                }

                if (NeedSave != null)
                    NeedSave(this, EventArgs.Empty);
            }
            finally
            {
                _lock.ReleaseWriterLock();
            }

            RefreshTimer();
        }