Exemple #1
0
        /// <summary>
        /// Performs variations via the controller on another thread or process.
        /// </summary>
        /// <remarks>
        /// Variations may be executed on separate threads or processes
        /// depending on the ApplicationType specified in &lt;Dimensions /&gt;.
        /// </remarks>
        public void Perform(VariationItem variation)
        {
            _CurrentVariation = variation;

            _variationStartSignal.Set();

            _WaitForSignal(_variationDoneSignal);
        }
Exemple #2
0
        /// <summary>
        /// Loop function that runs on its own thread.
        /// It continuously waits for new variations from the
        /// controller proxy, and performs them here.  The loop terminates
        /// when the proxy signals that it is done (disposed).
        /// </summary>
        private void _RunLoop()
        {
            GlobalLog.LogStatus("Variation loop beginning...");

            // These are used to synchronize the main controller with this proxy.
            // For each variation, the main controller sets the xml in storage, signals
            // the proxy to run it, and waits for it to finish.
            EventWaitHandle controllerInitializedSignal = EventWaitHandle.OpenExisting("Controller_InitializedSignal");
            EventWaitHandle variationStartSignal        = EventWaitHandle.OpenExisting("VariationStartSignal");
            EventWaitHandle variationDoneSignal         = EventWaitHandle.OpenExisting("VariationDoneSignal");


            // Signal to the main controller that our initialization is done.
            _SetEvent(controllerInitializedSignal);

            try
            {
                //
                // Continuously wait for new variations to perform.
                // Exit when the controller proxy says we're done.
                //
                while (_WaitForSignal(variationStartSignal))
                {
                    // Run the current variation item.
                    VariationItem item = _CurrentVariation;

                    DispatcherOperation op = this.TestDispatcher.BeginInvoke(
                        DispatcherPriority.SystemIdle,
                        (DispatcherOperationCallback) delegate(object obj)
                    {
                        item.Execute();
                        return(null);
                    },
                        null);

                    _WaitForOperation(op);

                    // Let the controller proxy know that the variation
                    // is has completed.
                    _SetEvent(variationDoneSignal);
                }

                this.EndTest();
            }
            catch (Exception exception)
            {
                if (TestLog.Current != null)
                {
                    TestLog.Current.LogEvidence("Unexpected exception:\r\n" + exception.ToString());
                    TestLog.Current.Result = TestResult.Fail;
                }
                else
                {
                    GlobalLog.LogStatus("Unexpected exception:\r\n" + exception.ToString());
                }
            }
            finally
            {
                GlobalLog.LogStatus("Variation loop exiting...");
                _IsVariationLoopDone = true;
            }
        }