Ejemplo n.º 1
0
        /// <summary>
        ///     Acquires a composite PooledServiceActivity that holds a reference to the underlying activity, once you are done
        ///     working
        ///     with the activity you must return it to the pool via PushActivity.
        /// </summary>
        /// <returns></returns>
        public PooledServiceActivity PopActivity()
        {
            PooledServiceActivity result;

            lock (_poolGuard)
            {
                if (_workflowPool.Count == 0)
                {
                    if (_xamlStream == null)
                    {
                        result = new PooledServiceActivity(_generation, _workflowActivity);
                    }
                    else
                    {
                        Activity activity = ActivityXamlServices.Load(_xamlStream);
                        _xamlStream.Seek(0, SeekOrigin.Begin);
                        result = new PooledServiceActivity(_generation, activity);
                    }
                }
                else
                {
                    result = _workflowPool.Dequeue();
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Pushes a previously released activity back into the activity pool.
 /// </summary>
 /// <param name="activity"></param>
 public void PushActivity(PooledServiceActivity activity)
 {
     if (activity != null)
     {
         lock (_poolGuard)
         {
             if (activity.Generation == _generation)
             {
                 if (_workflowPool.Count < 10)
                 {
                     if (_xamlStream != null)
                     {
                         _workflowPool.Enqueue(activity);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Pushes a previously released activity back into the activity pool.
 /// </summary>
 /// <param name="activity"></param>
 public void PushActivity(PooledServiceActivity activity)
 {
     if (activity != null)
     {
         lock (_poolGuard)
         {
             if (activity.Generation == _generation)
             {
                 if (_workflowPool.Count < 10)
                     if (_xamlStream != null)
                         _workflowPool.Enqueue(activity);
             }
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Acquires a composite PooledServiceActivity that holds a reference to the underlying activity, once you are done
        ///     working
        ///     with the activity you must return it to the pool via PushActivity.
        /// </summary>
        /// <returns></returns>
        public PooledServiceActivity PopActivity()
        {
            PooledServiceActivity result;

            lock (_poolGuard)
            {
                if (_workflowPool.Count == 0)
                {
                    if (_xamlStream == null)
                    {
                        result = new PooledServiceActivity(_generation, _workflowActivity);
                    }
                    else
                    {
                        Activity activity = ActivityXamlServices.Load(_xamlStream);
                        _xamlStream.Seek(0, SeekOrigin.Begin);
                        result = new PooledServiceActivity(_generation, activity);
                    }
                }
                else result = _workflowPool.Dequeue();
            }

            return result;
        }