/// <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; } } }
/// <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; } } }
/// <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; } } } } }
/// <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; } } } } }