コード例 #1
0
        private void threadItemExecute(object state)
        {
            while (!_isStop)
            {
                IThreadQueueExecuteItem item = null;

                if (_queue.TryDequeue(out item) && !_isStop)
                {
                    try
                    {
                        item.Execute(item.State);
                    }
                    catch (Exception)
                    {
                    }

                    Thread.Sleep(100);
                }
                else
                {
                    Thread.Yield();
                    Thread.Sleep(200);
                }
            }
        }
コード例 #2
0
        public void Execute(IThreadQueueExecuteItem executeItem)
        {
            if (_isClosed)
            {
                return;
            }

            _queue.Enqueue(executeItem);
        }
コード例 #3
0
        public void Execute(IThreadQueueExecuteItem executeItem)
        {
            if (_isClosed)
            {
                return;
            }

            lock (lockerObj)
            {
                workQueue.Enqueue(executeItem);
                au.Set();
            }
        }
コード例 #4
0
 public void Clear()
 {
     try
     {
         if (!_queue.IsEmpty)
         {
             IThreadQueueExecuteItem item = null;
             while (!_queue.IsEmpty)
             {
                 _queue.TryDequeue(out item);
             }
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #5
0
        private void run(object state)
        {
            IThreadQueueExecuteItem processItem = null;

            while (true)
            {
                lock (workQueue)
                {
                    if (workQueue.Count <= 0)
                    {
                        processItem = null;
                    }
                    else
                    {
                        processItem = workQueue.Dequeue();
                    }
                }

                if (processItem == null)
                {
                    au.WaitOne(500);
                }
                else
                {
                    try
                    {
                        processItem.Execute(state);
                    }
                    catch
                    {
                    }

                    Thread.Yield();
                    Thread.Sleep(100);
                }
            }
        }