/// <summary> /// DR module initialization /// </summary> /// <param name="objectParameters"></param> public static void DRInit(object objectParameters) { moduleControlDataBlock = (ModuleControlDataBlock)objectParameters; threadParameters = moduleControlDataBlock.ThreadParameters; try { // Initialize Ready/Abort Event and threadpool ModuleReadyEvent = threadParameters.ModuleReadyEvent; ModuleAbortEvent = threadParameters.ModuleAbortEvent; Clients = new List <Socket>(); ClientThreadList = new List <Thread>(); ConnectionEvent = new ManualResetEvent(false); CommunicationDictionary = new Dictionary <Socket, CommunicationBase>(); // Set listener socket configuration Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Listener.Bind(new IPEndPoint(IPAddress.Any, ListenPort)); ListenThread = new Thread(ListenWork); ModuleReadyEvent.Set(); Log.GeneralEvent .Write("DRInit complete Phase 1 Initialization"); // Wait for core StartWork Signal ModuleStartWorkEvent = threadParameters.ModuleStartWorkEvent; ModuleStartWorkEvent.WaitOne(); Log.GeneralEvent .Write("DRInit complete Phase 2 Initialization"); ListenThread.Start(); Log.GeneralEvent.Write("DR module is working..."); // Check ModuleAbortEvent periodically SpinWait.SpinUntil(() => !ModuleAbortEvent .WaitOne((int)TimeInterval.VeryVeryShortTime)); Log.GeneralEvent.Write("DR module is aborting."); } catch (Exception ex) { Log.ErrorEvent.Write(ex.Message); Log.ErrorEvent.Write("DR module thread failed."); threadParameters.ModuleInitFailedEvent.Set(); Log.ErrorEvent.Write("DR ModuleInitFailedEvent Set"); } CleanupExit(); }
public ModuleControlDataBlock() { ThreadParameters = new ThreadParameters(); }