Changeset 5280 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
- Timestamp:
- 01/11/11 17:29:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r5158 r5280 24 24 using System.IO; 25 25 using System.Runtime.CompilerServices; 26 using System.ServiceModel; 26 27 using System.Threading; 27 28 using HeuristicLab.Clients.Hive.Slave; … … 39 40 public class Core : MarshalByRefObject { 40 41 public static bool abortRequested { get; set; } 42 private Semaphore waitShutdownSem = new Semaphore(0, 1); 41 43 public static ILog Log { get; set; } 42 44 … … 50 52 51 53 private ISlaveCommunication ClientCom; 54 private ServiceHost slaveComm; 52 55 53 56 public Dictionary<Guid, Executor> ExecutionEngines { … … 60 63 61 64 public Core() { 65 } 66 67 /// <summary> 68 /// Main Method for the client 69 /// </summary> 70 public void Start() { 62 71 coreThreadId = Thread.CurrentThread.ManagedThreadId; 63 }64 65 /// <summary>66 /// Main Method for the client67 /// </summary>68 public void Start() {69 72 abortRequested = false; 73 74 //start the client communication service (pipe between slave and slave gui) 75 slaveComm = new ServiceHost(typeof(SlaveCommunicationService)); 76 slaveComm.Open(); 70 77 71 78 ClientCom = SlaveClientCom.Instance.ClientCom; … … 82 89 83 90 DeRegisterServiceEvents(); 91 waitShutdownSem.Release(); 84 92 } 85 93 … … 110 118 void wcfService_ExceptionOccured(object sender, EventArgs<Exception> e) { 111 119 ClientCom.LogMessage("Connection to server interruped with exception: " + e.Value.Message); 112 ShutdownCore();113 120 } 114 121 … … 159 166 } 160 167 161 public void ShutdownCore() { 168 public void Shutdown() { 169 MessageContainer mc = new MessageContainer(MessageContainer.MessageType.ShutdownSlave); 170 MessageQueue.GetInstance().AddMessage(mc); 171 waitShutdownSem.WaitOne(); 172 } 173 174 private void ShutdownCore() { 162 175 ClientCom.LogMessage("Shutdown Signal received"); 163 176 ClientCom.LogMessage("Stopping heartbeat"); … … 165 178 abortRequested = true; 166 179 ClientCom.LogMessage("Logging out"); 180 167 181 168 182 lock (engines) { … … 177 191 ClientCom.Shutdown(); 178 192 SlaveClientCom.Close(); 193 194 if (slaveComm.State != CommunicationState.Closed) 195 slaveComm.Close(); 179 196 } 180 197
Note: See TracChangeset
for help on using the changeset viewer.