private void TurnPrimary(ProcessDiedEventArgs evArg) { m_form.SetMode(true); m_disp = new OrderDispatcher(true); m_disp.ElevNumberChanged += m_form.SetElevCount; m_disp.EventHappened += ((e) => m_form.AddHistoryMsg(e.GetInfoString())); m_proc = new PrimaryProcessNotifier(); m_proc.ProcessDied += ((e) => m_form.AddHistoryMsg(e.Time.ToLongTimeString() + ": Backup stopped working, restarting backup")); m_proc.ProcessDied += ((e) => m_proc.Start()); StartProgram(); m_proc.Start(); }
/// <summary> /// Determines mode and starts process-pair mechanisms /// </summary> /// <param name="args"> Command line arguments, indicate mode </param> /// <param name="form"> The actual window </param> public Regulator(string[] args, Form1 form) { m_started = false; m_form = form; if (args.Length == 1) { // backup cmd parameters: <tcpport> m_disp = null; m_proc = new BackupProcessNotifier(Convert.ToInt32(args[0])); m_proc.ProcessDied += ((e) => m_form.AddHistoryMsg(e.Time.ToLongTimeString() + ": Primary stopped working, turning primary") ); m_proc.ProcessDied += TurnPrimary; m_form.InternSetMode(false); } else { // No args: primary, default port 55555 m_disp = new OrderDispatcher(false); m_disp.ElevNumberChanged += m_form.SetElevCount; m_disp.EventHappened += ((e) => m_form.AddHistoryMsg(e.GetInfoString())); m_proc = new PrimaryProcessNotifier(); m_proc.ProcessDied += ((e) => m_form.AddHistoryMsg(e.Time.ToLongTimeString() + ": Backup stopped working, restarting backup")); m_proc.ProcessDied += ((e) => m_proc.Start()); } m_proc.Start(); }