Exemplo n.º 1
0
        public void Start()
        {
            WorkerBlock.Reset();
            StartWait.Reset();

            ConsumeWorker = new Thread(new ThreadStart(WorkerFunc));
            ConsumeWorker.Start();

            StartWait.WaitOne(10 * 1000);
        }
Exemplo n.º 2
0
        private void WorkerFunc()
        {
            string line;
            bool   DeviceNotConnected = true;

            try
            {
                WorkingProcess = Process.Start(Psi);
            }
            catch
            {
                StartWait.Set();
                return;
            }

            Running = true;

            StartWait.Set();

            while (Consume)
            {
                line = WorkingProcess.StandardOutput.ReadLine();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (line.StartsWith("-") || line.StartsWith("*"))
                {
                    continue;
                }

                if (DeviceNotConnected)
                {
                    DeviceNotConnected = false;

                    if (OnLineOutputReceive != null)
                    {
                        OnLineOutputReceive("DEVCON");
                    }
                }

                if (OnLineOutputReceive != null)
                {
                    OnLineOutputReceive(line);
                }
            }

            WorkerBlock.Set();
        }