static void RunAsyncLoadTest() { while (true) { LoadData ld; lock (loadQueue) { if (loadQueue.Count == 0) { if (!Monitor.Wait(loadQueue, 5000, true)) { loaderRunning = false; return; } } ld = (LoadData)loadQueue.Dequeue(); } try { // If the information is cached in a file and it is up to date information, // there is no need to parse again the assembly. if (ld.TestInfoCachePath != null && File.Exists(ld.TestInfoCachePath)) { ld.InfoCache = TestInfoCache.Read(ld.TestInfoCachePath); NunitTestInfo info = ld.InfoCache.GetInfo(ld.Path); if (info != null) { ld.Info = info; ld.Callback(ld); continue; } } } catch (Exception ex) { LoggingService.LogError(ex.ToString()); } ExternalTestRunner runner = null; try { if (File.Exists(ld.Path)) { runner = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(ExternalTestRunner), false); ld.Info = runner.GetTestInfo(ld.Path, ld.SupportAssemblies); } } catch (Exception ex) { Console.WriteLine(ex); ld.Error = ex; } finally { try { if (runner != null) { runner.Dispose(); } } catch {} } try { ld.Callback(ld); } catch { } } }
static void RunAsyncLoadTest() { while (true) { LoadData ld; lock (loadQueue) { if (loadQueue.Count == 0) { if (!Monitor.Wait(loadQueue, 5000, true)) { loaderRunning = false; return; } } ld = (LoadData)loadQueue.Dequeue(); } try { // If the information is cached in a file and it is up to date information, // there is no need to parse again the assembly. if (ld.TestInfoCachePath != null && File.Exists(ld.TestInfoCachePath)) { ld.InfoCache = TestInfoCache.Read(ld.TestInfoCachePath); NunitTestInfo info = ld.InfoCache.GetInfo(ld.Path); if (info != null) { ld.Info = info; ld.Callback(ld); continue; } } } catch (Exception ex) { LoggingService.LogError(ex.ToString()); } ExternalTestRunner runner = null; try { if (File.Exists(ld.Path)) { runner = new ExternalTestRunner(Path.GetDirectoryName(ld.Path)); runner.ProcessExecutionArchitecture = AssemblyUtilities.GetProcessExecutionArchitectureForAssembly(ld.Path); runner.Connect(ld.NUnitVersion).Wait(); var supportAssemblies = new List <string> (ld.SupportAssemblies.Result); ld.Info = runner.GetTestInfo(ld.Path, supportAssemblies).Result; } } catch (AggregateException exception) { var baseException = exception.GetBaseException(); Console.WriteLine(baseException); ld.Error = baseException; } catch (Exception exception) { Console.WriteLine(exception); ld.Error = exception; } finally { try { if (runner != null) { runner.Dispose(); } } catch {} } try { ld.Callback(ld); } catch { } } }