/// <summary>
 /// Initializes a new instance of the <see cref="Scheduler{T}"/> class.
 /// </summary>
 public Scheduler()
 {
     IsDisposed   = false;
     mIsEnabled   = false;
     SyncRoot     = new object();
     mInterval    = TimeSpan.FromMinutes(1.0);
     TriggerTimer = new Timer(new TimerCallback(TriggerCallback), this, Timeout.Infinite, Timeout.Infinite);
     mTasks       = new NonBlockingConcurrentList <ScheduledTask <T> >();
     Init();
 }
        /// <summary>
        /// Releases allocated resources.
        /// </summary>
        /// <param name="disposing">A value indicating if the method was called by user code. If <see langword="false"/>, the method was called by the runtime in the finalizer.</param>
        /// <remarks>If <paramref name="disposing"/> is <see langword="false"/>, no other objects should be referenced.</remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            try
            {
                if (disposing)
                {
                    if (mIsEnabled)
                    {
                        Stop();
                    }
                    if (TriggerTimer != null)
                    {
                        TriggerTimer.Dispose();
                    }
                    if (mTasks != null)
                    {
                        foreach (ScheduledTask <T> task in mTasks)
                        {
                            task.Dispose();
                        }
                        mTasks.Clear();
                    }
                    if (ScheduledTasks != null)
                    {
                        ScheduledTasks.Dispose();
                    }
                }
            }
            finally
            {
                IsDisposed = true;
            }
            TriggerTimer   = null;
            mTasks         = null;
            ScheduledTasks = null;
        }
		public void AddWhileEnum()
		{
			NonBlockingConcurrentList<int> lst = new NonBlockingConcurrentList<int>();
			lst.Add(1);
			lst.Add(2);
			lst.Add(3);
			lst.Add(4);
			int i = 0;

			foreach (int j in lst)
			{
				i++;
				if (i == 2)
				{
					lst.Add(5);
					Assert.AreEqual(5, lst.Count);
				}
			}

			Assert.AreEqual(5, lst.Count);
		}