/// <summary> /// Thread for autoconnect to remote application /// </summary> // /// <param name="sender">Unused</param> protected override void MainThreadTask() { Thread thisThread; StatusChangedEH busyEH; StatusChangedEH readyEH; ModuleConnectionEH connectedStatusEH; stopMainThread = false; running = true; Busy = false; IsAlive = true; Ready = true; #region Setup EventHandlers busyEH = new StatusChangedEH(module_BusyChanged); readyEH = new StatusChangedEH(module_ReadyChanged); connectedStatusEH = new ModuleConnectionEH(module_ConnectedStatusChanged); if (this.Parent != null) { foreach (IModuleClient module in Parent.Modules) { if (module == this) { continue; } module.BusyChanged += busyEH; module.ReadyChanged += readyEH; if (module is ModuleClient) { ((ModuleClient)module).Connected += connectedStatusEH; ((ModuleClient)module).Disconnected += connectedStatusEH; } } } #endregion // Fills out MachineStatuss List FillMachineStatussList(); while (running && !stopMainThread) { // Parse received data ParsePendingCommands(); } #region Clear EventHandlers if (this.Parent != null) { foreach (IModuleClient module in Parent.Modules) { if (module == this) { continue; } module.BusyChanged -= busyEH; module.ReadyChanged -= readyEH; if (module is ModuleClient) { ((ModuleClient)module).Connected -= connectedStatusEH; ((ModuleClient)module).Disconnected -= connectedStatusEH; } } } #endregion running = false; OnStopped(); OnStatusChanged(); #region Stop and Clear Thread thisThread = mainThread; mainThread = null; #endregion }
public FrmBlackboard() { InitializeComponent(); frmBbss = new FrmBlackboardSecondaryScreen(this); this.scTop.Panel2MinSize = 257; SetupShutdownModeControls(); SetupStartupModeControls(); //TextBoxStreamWriter tbsw = new TextBoxStreamWriter(txtOutputLog); //tbsw.AppendDate = true; //log = new LogWriter(tbsw); moduleButtons = new SortedList<string, Button>(); moduleButtonsClone = new SortedList<string, Button>(); frmBbss.GbBlackboardFiles.Enabled = gbBlackboardFiles.Enabled = true; gbBlackboardSettings.Enabled = false; frmBbss.GbModuleList.Enabled = gbModuleList.Enabled = false; btnStartStop.Enabled = false; frmBbss.BtnStartStop.Enabled = false; this.Icon = Properties.Resources.star2_48; updateModuleInfo = new VoidEventHandler(UpdateModuleInfo); rmsList = new Dictionary<IPAddress, MachineStatusControl>(); tcLog.SelectedTab = tpOutputLog; this.chkAutoLog.Checked = true; dlgMslMachineStatusAdded = new MachineStatusAddRemoveEH(MachineStatusList_MachineStatusAdded); dlgMslMachineStatusRemoved = new MachineStatusAddRemoveEH(MachineStatusList_MachineStatusRemoved); dlgMslMachineStatusChanged = new MachineStatusElementChangedEH(MachineStatusList_ElementChanged); dlgBbStatusChanged = new VoidEventHandler(bbStatusChanged); dlgModuleStatusChanged = new StatusChangedEH(module_StatusChanged); dlgShvSharedVariableAdded = new SharedVariableAddedEventHandler(SharedVariables_SharedVariableAdded); dlgSetupBlackboardModule = new IModuleAddRemoveEH(SetupBlackboardModule); #if !SPEED_UP this.redirectionHistoryColumn = lvwRedirectionHistory.Columns.IndexOf(chCommandSent); dispatchedCommands = new List<ITextCommand>(10000); dlgBlackboardResponseRedirected = new ResponseRedirectedEH(blackboard_ResponseRedirected); dlgAddRedirectionListItem = new AddRedirectionListItemEH(AddRedirectionListItem); #else tcLog.TabPages.Remove(tpMessagePendingList); tcLog.TabPages.Remove(tpRedirectionHistory); #endif }