/// <summary> Main rx loop which waits for commands and then issues them to anyone listening.</summary> internal virtual void listenForMessages() { DProtocolNotifierIF[] listeners = new DProtocolNotifierIF[0]; while (!m_stopRx) { /* read the data */ try { DMessage msg = rxMessage(); /* Now traverse our list of interested parties and let them deal with the message */ listeners = (DProtocolNotifierIF[])m_listeners.ToArray(typeof(DProtocolNotifierIF)); // copy the array to avoid multithreading problems for (int i = 0; i < listeners.Length; ++i) { DProtocolNotifierIF elem = listeners[i]; try { elem.messageArrived(msg, this); } catch (Exception exc) /* catch unchecked exceptions */ { if (Trace.error) { Console.Error.WriteLine("Error in listener parsing incoming message :"); //$NON-NLS-1$ Console.Error.WriteLine(msg.inToString(16)); Console.Error.Write(exc.StackTrace); Console.Error.Flush(); } } msg.reset(); /* allow others to reparse the message */ } /* now dispose with the message */ DMessageCache.free(msg); } //catch (IOException e) //{ // // this is a healthy exception that we simply ignore, since it means we haven't seen // // data for a while; is all. //} finally { } } }