Example #1
0
        /// <summary>
        /// Attempt to add an item to a <see cref="BoundedBuffer"/>.
        /// </summary>
        /// <param name="activator">
        /// The object that activated this <see cref="BufferPut"/> task.
        /// </param>
        /// <param name="data">
        /// Optional data for the <see cref="BufferPut"/> task.  This will
        /// normally be <see langword="null"/> or the item to add to the
        /// <see cref="BoundedBuffer"/>.
        /// </param>
        protected override void ExecuteTask(object activator, object data)
        {
            System.Diagnostics.Debug.Assert(activator != Blocker);

            if (Client != null)
            {
                if (Item == null)
                {
                    Blocker.PutObject(this);
                }
                else
                {
                    Blocker.PutObject(this, Item);
                }
            }
            else
            {
                ResumeAll(Blocker, null);
            }
        }