1 // ****************************************************************
2 // Copyright 2007, Charlie Poole
3 // This is free software licensed under the NUnit license. You may
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
5 // ****************************************************************
9 using System
.Threading
;
10 using System
.Collections
.Specialized
;
13 /// ThreadedTestRunner overrides the Run and BeginRun methods
14 /// so that they are always run on a separate thread. The actual
16 public class ThreadedTestRunner
: ProxyTestRunner
18 #region Instance Variables
19 private TestRunnerThread testRunnerThread
;
23 public ThreadedTestRunner( TestRunner testRunner
) : base ( testRunner
) { }
27 public override TestResult
Run( EventListener listener
)
33 public override TestResult
Run( EventListener listener
, ITestFilter filter
)
35 BeginRun( listener
, filter
);
39 public override void BeginRun( EventListener listener
)
41 testRunnerThread
= new TestRunnerThread( this.TestRunner
);
43 testRunnerThread
.StartRun( listener
);
46 public override void BeginRun( EventListener listener
, ITestFilter filter
)
48 testRunnerThread
= new TestRunnerThread( this.TestRunner
);
50 testRunnerThread
.StartRun( listener
, filter
);
53 public override TestResult
EndRun()
56 return this.TestRunner
.TestResult
;
60 public override void Wait()
62 if ( testRunnerThread
!= null )
63 testRunnerThread
.Wait();
66 public override void CancelRun()
68 if ( testRunnerThread
!= null )
69 testRunnerThread
.Cancel();