/// <summary> /// Detiene el consumidor de eventos /// </summary> public void stopEventConsumer() { lock (eventConsumerLock) { eventConsumerStarted = false; try { eventConsumer.Abort(); } catch (Exception) { } try { eventQueuePC.unblok(); } catch (Exception) { } try { eventConsumer.Join(); } catch (Exception) { } eventQueuePC = new EventQueuePC(); } }
/// <summary> /// Constructo Parametrizado /// </summary> /// <param name="configuration">El objeto con los datos de configuraciĆ³n previamente llenado</param> /// <param name="subProtocols">Lista de SubProtocolos</param> /// <param name="extraMessageTypes">Tipos de mensajes no especificados en los sub protocolos</param> public Communication(Configuration configuration, SubProtocolList subProtocols, MessageTypeList extraMessageTypes) { try { this.configuration = configuration; if (extraMessageTypes != null) { messageTypes = extraMessageTypes.Collection; } else { messageTypes = new Hashtable(); } if (subProtocols != null) { Hashtable sub = subProtocols.Collection; foreach (DictionaryEntry en in sub) { SubProtocolI subProtocol = (SubProtocolI)en.Value; Hashtable spMessageTypes = subProtocol.getMessageTypes().Collection; foreach (DictionaryEntry de in spMessageTypes) { messageTypes.Add(de.Key, de.Value); } subProtocol.sendMessageEvent += internalSendMessage; } this.subProtocols = sub; } netHandler = new NetHandler(configuration.NetData, this); eventQueuePC = new EventQueuePC(); eventConsumer = new Thread(new ThreadStart(consumeEvent)); eventConsumerStarted = false; eventConsumerLock = new Object(); init(); } catch (ThreadAbortException e) { throw e; } catch (Exception e) { throw e; } }