示例#1
0
        private void WorkerThreadThunk(Object stateInfo)
        {
            ConcurrentTestStepWrapper step = (ConcurrentTestStepWrapper)stateInfo;

            step.Execute();

            // This step is completed, add to queue
            lock (this.completedConcurrentSteps.SyncRoot)
            {
                this.completedConcurrentSteps.Enqueue(step);
            }
        }
示例#2
0
        private void FlushConcurrentQueue(bool waitingToFinish)
        {
            if (waitingToFinish && this.inflightQueueDepth == 0)
            {
                return;
            }

            while ((this.completedConcurrentSteps.Count > 0) || waitingToFinish)
            {
                object obj = null;

                lock (this.completedConcurrentSteps.SyncRoot)
                {
                    if (this.completedConcurrentSteps.Count > 0)
                    {
                        try
                        {
                            obj = this.completedConcurrentSteps.Dequeue();
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                if (null != obj)
                {
                    ConcurrentTestStepWrapper step = (ConcurrentTestStepWrapper)obj;
                    string testLog = step.GetLogText();
                    this.logger.WriteLine(testLog);

                    this.logger.WriteLine(string.Format("Step: {0} ended @ {1} (Concurrent Execution Mode defined)", step.Name, GetNow()));

                    // Check to see if the test step failed, if it did throw the exception...
                    if (null != step.FailureException)
                    {
                        Interlocked.Decrement(ref this.inflightQueueDepth);
                        throw step.FailureException;
                    }

                    Interlocked.Decrement(ref this.inflightQueueDepth);
                }

                if (waitingToFinish && (this.inflightQueueDepth > 0))
                {
                    Thread.Sleep(250);
                }
                else if (waitingToFinish && (this.inflightQueueDepth == 0))
                {
                    break;
                }
            }
        }