Example #1
0
		/// <summary>
		/// Add new task.
		/// </summary>
		/// <param name="idleTask">Task.</param>
		public void AddTask(IOnIdleTask idleTask)
		{
			if(idleTask == null)
			{
				throw new ArgumentNullException("idleTask");
			}
			lock(_tasks)
			{
				idleTask.Service = this;
				_tasks.Add(idleTask);
				if(!_registered)
				{
					Application.Idle += StartCycle;
					_registered = true;
				}
			}
		}
Example #2
0
 /// <summary>
 /// Add new task.
 /// </summary>
 /// <param name="idleTask">Task.</param>
 public void AddTask(IOnIdleTask idleTask)
 {
     if (idleTask == null)
     {
         throw new ArgumentNullException("idleTask");
     }
     lock (_tasks)
     {
         idleTask.Service = this;
         _tasks.Add(idleTask);
         if (!_registered)
         {
             Application.Idle += StartCycle;
             _registered       = true;
         }
     }
 }
Example #3
0
		/// <summary>
		/// Remove task.
		/// </summary>
		/// <param name="idleTask">Task.</param>
		public void RemoveTask(IOnIdleTask idleTask)
		{
			if(idleTask != null)
			{
				lock(_tasks)
				{
					if(_tasks.Contains(idleTask))
					{
						_tasks.Remove(idleTask);
						if(_registered && _tasks.Count == 0)
						{
							Application.Idle -= StartCycle;
							_registered = false;
						}
					}
				}
			}
		}
Example #4
0
 /// <summary>
 /// Remove task.
 /// </summary>
 /// <param name="idleTask">Task.</param>
 public void RemoveTask(IOnIdleTask idleTask)
 {
     if (idleTask != null)
     {
         lock (_tasks)
         {
             if (_tasks.Contains(idleTask))
             {
                 _tasks.Remove(idleTask);
                 if (_registered && _tasks.Count == 0)
                 {
                     Application.Idle -= StartCycle;
                     _registered       = false;
                 }
             }
         }
     }
 }