Exemple #1
0
 internal AsyncWorkItem NextWorkItem()
 {
     lock (_queue.SyncRoot)
     {
         if (_queue.Count == 0)
         {
             return(null);
         }
         AsyncWorkItem result = (AsyncWorkItem)_queue.Dequeue();
         if (_queue.Count == 0)
         {
             _hasPendingPost = false;
         }
         return(result);
     }
 }
Exemple #2
0
        private void AddItem(AsyncWorkItem item)
        {
            bool flag = true;

            lock (_queue.SyncRoot)
            {
                if (Enabled)
                {
                    _queue.Enqueue(item);
                    if (!_hasPendingPost || !_isAsyncMode)
                    {
                        flag            = false;
                        _hasPendingPost = true;
                    }
                }
            }
            if (!flag)
            {
                OnWorkItemPending();
            }
        }