/// <summary>
        /// A thread method that waits for work on its queue and then processes that work via
        /// the context's workflow engine.
        /// </summary>
        protected void ProcessRequestThread(object state)
        {
            ThreadSemaphore ts = (ThreadSemaphore)state;

            while (true)
            {
                ts.WaitOne();
                WorkflowContext context;

                if (ts.TryDequeue(out context))
                {
                    // Continue with where we left off for this context's workflow.
                    context.WorkflowContinuation.Workflow.Continue(context.WorkflowContinuation, context.Context);
                }
            }
        }
        /// <summary>
        /// A thread method that waits for work on its queue and then processes that work via
        /// the context's workflow engine.
        /// </summary>
        protected void ProcessRequestThread(object state)
        {
            ThreadSemaphore ts = (ThreadSemaphore)state;

            while (true)
            {
                ts.WaitOne();
                WorkflowContext context;

                if (ts.TryDequeue(out context))
                {
                    // Wait until we exit the workflow internal continue from a defering state.
                    while (!context.WorkflowContinuation.Deferred)
                    {
                        Thread.Sleep(0);
                    }
                    // Continue with where we left off for this context's workflow.
                    context.WorkflowContinuation.Workflow.Continue(context.WorkflowContinuation, context.Context);
                }
            }
        }