Esempio n. 1
0
        /// <summary> Initializes this object. </summary>
        /// <param name="receiveCommandQueue"></param>
        /// <param name="commandSeparator">    The End-Of-Line separator. </param>
        /// <param name="fieldSeparator"></param>
        /// <param name="escapeCharacter"> The escape character. </param>
        /// <param name="disposeStack"> The DisposeStack</param>
        /// /// <param name="transport"> The Transport Layer</param>
        public void Initialize(DisposeStack disposeStack, ITransport transport, ReceiveCommandQueue receiveCommandQueue, char commandSeparator, char fieldSeparator, char escapeCharacter)
        {
            disposeStack.Push(this);
            _transport                  = transport;
            _receiveCommandQueue        = receiveCommandQueue;
            _transport.NewDataReceived += NewDataReceived;
            _commandSeparator           = commandSeparator;
            _fieldSeparator             = fieldSeparator;
            _escapeCharacter            = escapeCharacter;

            _isEscaped = new IsEscaped();
        }
Esempio n. 2
0
        /// <summary> Constructor. </summary>
        /// <param name="disposeStack">Dispose stack to add itself to</param>
        /// <param name="interval"> The execution interval. </param>
        /// <param name="action">   The action to execute. </param>
        public TimedAction(DisposeStack disposeStack, double interval, Action action)
        {
            disposeStack.Push(this);
            _action      = action;
            _threadState = new ThreadState {
                IsRunning = false
            };


            _actionTimer = new Timer(interval)
            {
                Enabled = false, SynchronizingObject = null
            };
            _actionTimer.Elapsed += OnActionTimer;
        }
Esempio n. 3
0
        /// <summary> command queue constructor. </summary>
        /// <param name="disposeStack"> DisposeStack. </param>
        /// <param name="cmdMessenger"> The command messenger. </param>
        public CommandQueue(DisposeStack disposeStack, CmdMessenger cmdMessenger)
        {
            CmdMessenger = cmdMessenger;
            disposeStack.Push(this);

            // Create queue thread and wait for it to start
            QueueThread = new Thread(ProcessQueue)
            {
                Priority = ThreadPriority.Normal
            };
            QueueThread.Start();
            while (!QueueThread.IsAlive && QueueThread.ThreadState != ThreadState.Running)
            {
                Thread.Sleep(TimeSpan.FromMilliseconds(25));
            }
        }