private void Initialize(bool checkItemCount, string threadSuffix) { using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "Initialize")) { try { _uniqueKey = "AsyncTaskThreadPoolExecutor_" + Guid.NewGuid().ToString(); method.InfoV("{0} : Capacity : {1:D}, Queue Capacity : {2:D}", _uniqueKey, this.Capacity, this.QueueCapacity); this.RegisterForShutdown(); this.ExecutorService.AddExecutor(this); for (int i = 0; i < this.Capacity; i++) { AsyncTaskThreadExecutor <T> executor = new AsyncTaskThreadExecutor <T>(this.ThreadExecutorService, this.QueueCapacity, checkItemCount, threadSuffix); executor.ProcessItem += new ExecutorProcessItemHandler <T>(OnExecutor_ProcessItem); executor.ProcessItemCompleted += new ExecutorProcessItemCompletedHandler2 <T>(OnExecutor_ProcessItemCompleted); executor.ContainerIndex = i; _workerThreads.Add(executor); _activeWorkersCount.Add(executor.UniqueKey, new ThreadHashValue() { Executor = executor, ItemCount = 0 }); } } catch (Exception ex) { method.Exception(ex); } } }
public int CompareTo(AsyncTaskThreadExecutor <T> other) { if (other == null) { return(1); } return(string.Compare(_uniqueKey, other._uniqueKey, true)); }
protected override bool IsQueueFull(AsyncTaskThreadExecutor <T> executor, T item) { return(executor.ItemCount == executor.QueueCapacity); }