/// <summary> /// Adds a new thread to the thread pool /// </summary> /// <param name="aThread">The thread to be added</param> public void AddThread(ISynchronizedThread aThread) { if (aThread.ThreadState == ThreadState.Running) { aThread.Abort(); } Logger.Trace("COM: Pushing new thread into the thread queue."); ThreadQueue.Enqueue(aThread); if (Count != 1 || _isThreadRunning) { return; } Logger.Trace("COM: Thread was added therefore the corresponding event is fired."); OnThreadAdded?.Invoke(new object(), new EventArgs()); }
/// <summary> /// Adds a new thread to the thread pool /// </summary> /// <param name="aThread">The thread to be added</param> public void AddThread(ISynchronizedThread aThread) { if (aThread.ThreadState != ThreadState.Unstarted) { throw new ArgumentException(nameof(aThread)); } Logger.Trace("COM: Pushing new thread into the thread queue."); ThreadQueue.Enqueue(aThread); if (Count != 1 || _isThreadRunning) { return; } Logger.Trace("COM: Thread was added therefore the corresponding event is fired."); OnThreadAdded?.Invoke(this, new EventArgs()); }