public void Initialize(DispatcherSettings settings) { try { if (!DependencyResolver.IsInitialized) throw new InvalidOperationException("The DependencyResolver must be initialized before initializing the Dispatcher!"); settings.Validate(); Repository = new DispatcherRepository(settings); Repository.SubscribeToPoisonPill(TakePoisonPill); Repository.SubscribeToPendingJobs(ReceiveJob); Repository.StartSendingLifeSignal(); StartCheckingIfDispatcherShouldBeKeptAliveThatMuchTimeAfterInitialized(); ConfirmInitialization(); IsDisposed = false; } catch (Exception e) { Log.Error(e, "Could not initialize the Dispatcher."); throw new InvalidOperationException("Could not initialize the Dispatcher.", e); } }
private static void Load(string settingsFileName) { var settings = new DispatcherSettings(); try { //System.Threading.Thread.Sleep(3000);//DEBUG if (File.Exists(settingsFileName)) { using (var stream = new FileStream(settingsFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) settings.LoadFrom(stream); } else { var errorMessage = String.Format("Invalid script file: {0}", settingsFileName); Log.Info(errorMessage); Console.WriteLine(errorMessage); return; } settings.Validate(); Dispatcher = new Dispatcher(); Dispatcher.Disposed += (s, e) => { Environment.Exit(0); }; Dispatcher.Initialize(settings); } catch (Exception ex) { var errorMessage = String.Format("Could not load Computational Unit for {0}!", settings.DispatcherId); Log.Error(ex, errorMessage); Console.WriteLine(errorMessage); Environment.Exit(0); } }