private void TestThread() { try { using (var rootScope = _randPool.RootScope <SqlRandomizer>()) { Stopwatch watch = new Stopwatch(); SqlConnection con = null; try { NextConnection(ref con, rootScope.Current); if (_randPool.ReproMode) { using (var testScope = rootScope.NewScope <SqlRandomizer>()) { // run only once if repro file is provided RunTest(con, testScope, _katmaiTypes, watch); } } else { while (watch.Elapsed < TimeLimitDefault) { using (var testScope = rootScope.NewScope <SqlRandomizer>()) { RunTest(con, testScope, _katmaiTypes, watch); } if (rootScope.Current.Next(100) == 0) { // replace the connection NextConnection(ref con, rootScope.Current); } } } } finally { if (con != null) { con.Close(); } } } } catch (Exception e) { Console.WriteLine(e); } finally { if (Interlocked.Decrement(ref _runningThreads) == 0) { _endEvent.Set(); } } }
private static void TestThread() { try { using (var rootScope = _randPool.RootScope<SqlRandomizer>()) { Stopwatch watch = new Stopwatch(); SqlConnection con = null; try { NextConnection(ref con, rootScope.Current); if (_randPool.ReproMode) { using (var testScope = rootScope.NewScope<SqlRandomizer>()) { // run only once if repro file is provided RunTest(con, testScope, _katmaiTypes, watch); } } else { while (watch.Elapsed < TimeLimitDefault) { using (var testScope = rootScope.NewScope<SqlRandomizer>()) { RunTest(con, testScope, _katmaiTypes, watch); } if (rootScope.Current.Next(100) == 0) { // replace the connection NextConnection(ref con, rootScope.Current); } } } } finally { if (con != null) { con.Close(); } } } } catch (Exception e) { StringBuilder output = new StringBuilder(); output.Append(e.ToString()); output.AppendLine(); if (!_randPool.ReproMode) { // add .repro extention to enable easy delete on repro files string reproFile = Path.GetRandomFileName() + ".repro"; _randPool.SaveLastThreadScopeRepro(reproFile); output.AppendFormat("ReproFile (use with /repro:reproFilePath):{0}{1}{0}", Environment.NewLine, reproFile); } Console.WriteLine(output); } finally { if (Interlocked.Decrement(ref _runningThreads) == 0) _endEvent.Set(); } }