private void ThreadProc() { TestResult result = null; TestDomain testDomain = null; TestConsoleAccess consoleAccess = new TestConsoleAccess(); try { log.DebugFormat("Thread entered for Test {0}:{1} Assembly {2}", mPNUnitTestInfo.TestName, mPNUnitTestInfo.TestToRun, mPNUnitTestInfo.AssemblyName); ConsoleWriter outStream = new ConsoleWriter(Console.Out); ConsoleWriter errorStream = new ConsoleWriter(Console.Error); testDomain = SetupTest(consoleAccess); if (testDomain == null) { return; } log.Debug("Running tests"); try { if (mConfig.NoTimeout) { result = RunTest(outStream, testDomain); } else { RunTestWithTimeoutDelegate deleg = new RunTestWithTimeoutDelegate( RunTest); IAsyncResult ar = deleg.BeginInvoke(outStream, testDomain, null, new object()); if (!ar.AsyncWaitHandle.WaitOne(TEST_TIMEOUT, false)) { testDomain.CancelRun(); throw new Exception("Test timeout exception"); } else { result = deleg.EndInvoke(ar); } } } catch (Exception e) { result = BuildError(e, consoleAccess); log.ErrorFormat("Error running test {0}", e.Message); } } finally { log.Info("Notifying the results"); log.Debug("////////////////////////////////////////Notifying the results/////////////////////////"); mPNUnitTestInfo.Services.NotifyResult( mPNUnitTestInfo.TestName, BuildResult(result, consoleAccess, mPNUnitTestInfo)); log.Debug("////////////////////////////////////////Results NOTIFIED/////////////////////////"); result = null; ReleaseDomain(testDomain); } }