/// <summary>
        /// Creates/Recreates the powersehll pipeline and ensures that everything is at a virgin state
        /// Starts the powershell pipeline and waits for it to request the first element from the pipeline
        /// The pipeline MUST be shutdown before calling this function! the reason for this is we cannot relaibly reset the BlockableEnum otherwise
        /// </summary>
        public void CreateAndBeginPipeline()
        {
            ResetRuleResults();

            // Create/reset writer into pipeline and the pipeline
            m_propertyBagWriter.ResetBlockableEnum();
            m_pipeLine = m_runSpace.CreatePipeline();

            m_powershellPaused[(int)m_waitHandleIndex.PipeLine] = m_pipeLine.Output.WaitHandle;

            // set the text of the pipeline and run it
            m_pipeLine.Commands.AddScript(m_scriptText);
            m_pipeLine.InvokeAsync();

            // wait for the pipeline to fail or request its first element
            m_waitHandleIndex lockIndex = 0;

            do
            {
                lockIndex = (m_waitHandleIndex)WaitHandle.WaitAny(m_powershellPaused);
            } while (lockIndex != m_waitHandleIndex.Enumerator && m_pipeLine.Output.IsOpen);

            // errors are not permitted before processing elements
            if (m_pipeLine.Error.Count > 0)
            {
                Exception error   = (Exception)m_pipeLine.Error.Read();
                string    message = string.Format(CultureInfo.InvariantCulture,
                                                  "Powershell Classifier threw errors before processing files in rule [{0}] - details: [{1}]",
                                                  m_ruleName,
                                                  error.Message);
                ThrowNonPropertyBagException(message, error);
            }

            // if pipeline terminated try and get termination reason
            if (m_pipeLine.Output.EndOfPipeline)
            {
                string message = string.Format(CultureInfo.InvariantCulture,
                                               "Powershell Classifier terminated abruptly before processing files in rule [{0}] - details: [{1}]",
                                               m_ruleName,
                                               m_pipeLine.PipelineStateInfo.Reason.Message);
                ThrowNonPropertyBagException(message, m_pipeLine.PipelineStateInfo.Reason);
            }
        }