public void ReleaseThread(ThreadObject threadObject) { lock (_lock) { _threads.Add(threadObject); } _threadReleasedEvent.Set(); }
private void ExecuteTaskAndReleaseThread(ThreadObject thread, Action task) { try { task(); } catch (Exception e) { // TODO(rpaquay): Do we want to propage the exception here? Logger.LogException(e, "Error executing task on custom thread pool."); } finally { ReleaseThread(thread); } }
private void ProcessQueueAndReleaseThread(ThreadObject thread) { try { ProcessQueue(); } finally { ReleaseThread(thread); } // There may have been more items enqueued concurrently: Mote tasks may have been // enueue we may have been // releasing the thread while // schedule another queue processing if needed bool queueIsEmpty; lock (_queueLock) { queueIsEmpty = _taskQueue.Count == 0; } if (!queueIsEmpty) { ProcessQueueAsync(); } }
private void ReleaseThread(ThreadObject thread) { thread.Release(); }