/// <summary> /// Thread delegate executing the jobs. /// </summary> private void ExecutionThread() { try { while (!_isDisposed) { try { IJob job = _jobs.Take(); job.Execute(); } catch (ObjectDisposedException) { // object has been disposed // we don't have anything to do, therefore leave lopp. break; } catch (Exception ex) { _log.Error(@"Execution of job failed.", ex); } } } finally { // this finally block will always get executed. _log.Info(@"Worker thread closed."); } }
/// <summary> /// Scan the file, which may or may not be an actual assembly. /// </summary> private IEnumerable <Type> ScanPossibleAssembly(string fileName, Predicate <Type> targeType) { IEnumerable <Type> handlers = null; try { AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileName); Assembly assembly = Assembly.Load(assemblyName); handlers = ScanAssembly(assembly, targeType); } catch (ReflectionTypeLoadException ex) { // assembly could not be scanned because of missing dependencies. _log.Error(@"Error scanning assembly.", ex); } catch (BadImageFormatException) { // file is not a .net assembly. _log.Info(@"Skip file scanning. File is not a .NET assembly: " + fileName); } return(handlers ?? new Type[0]); }