Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }