Esempio n. 1
0
        private void Work(WorkerInfo worker, object item)
        {
            if (worker == null)
            {
                return;
            }

            if (unique)
            {
                int n = workers.Sum(_worker => _worker.ContainsItem(item) ? 1 : 0);
                if (n == 0)
                {
                    worker.Work(item);
                }
            }
            else
            {
                worker.Work(item);
            }
        }
Esempio n. 2
0
        public void Work(object item)
        {
            lock (this)
            {
                if (this.dispatcher == null)
                {
                    string name = string.Format("调度线程 #{0}", this.Id);
                    this.dispatcher = new WorkerInfo(name, _ThreadProc);
                    this.dispatcher.Create();

#if DEBUG_THREAD
                    Log.Info(">> [{0}] 创建 {1}", Thread.CurrentThread.Name, name);
#endif
                }

                if (!dispatcher.ContainsItem(item))
                {
                    dispatcher.Work(item);
                }
            }
        }