예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logBuffer"></param>
        /// <param name="isClearBuffer">True : clear log buffer, False : unclear log buffer</param>
        public void Start(LogBuffer logBuffer, bool isClearBuffer)
        {
            if (!_isListener)
            {
                Action <IListener> startListener = null;
                l_listeners = new List <IListener>();
                L_Buffer    = logBuffer;
                if (L_Buffer.HasFlag(LogBuffer.Events))
                {
                    l_listeners.Add(new LogListerner(_device, LogBuffer.Events));
                }
                if (L_Buffer.HasFlag(LogBuffer.Main))
                {
                    l_listeners.Add(new LogListerner(_device, LogBuffer.Main));
                }
                if (L_Buffer.HasFlag(LogBuffer.Radio))
                {
                    l_listeners.Add(new LogListerner(_device, LogBuffer.Radio));
                }
                if (L_Buffer.HasFlag(LogBuffer.System))
                {
                    l_listeners.Add(new LogListerner(_device, LogBuffer.System));
                }
                if (startListener == null)
                {
                    startListener = delegate(IListener l)
                    {
                        l.LogDataReceivedEvent += this.OnLogDataReceived;
                        l.Start(isClearBuffer);
                    };
                }

                if (stopListener == null)
                {
                    stopListener = (l) => {
                        l.LogDataReceivedEvent -= this.OnLogDataReceived;
                        l.Stop(isClearBuffer);
                    };
                }

                Thread blockingT = new Thread(new ThreadStart(this.StartReceivedLogQueue));
                blockingT.Start();

                Parallel.ForEach <IListener>(l_listeners, startListener);

                _isListener = true;
            }
        }