Beispiel #1
0
        private static void StartEventMonitor()
        {
            autoEvent = new AutoResetEvent(false);
            isRunning = true;
            var thread = new Thread(() =>
            {
                while (isRunning)
                {
                    log.Debug("handle the evt");
                    if (queue.Count <= 0)
                    {
                        lock (synObject)
                        {
                            log.Info("No evt, wait..");
                            autoEvent.WaitOne();
                        }
                    }
                    while (queue.Count > 0)
                    {
                        QLEvent evt = null;
                        lock (synObject)
                        {
                            evt = queue.Dequeue();
                        }
                        // dispatch QLEvent to proper modules
                        if (evt == null)
                        {
                            log.Error("QLEvent is null!");
                            continue;
                        }
                        try
                        {
                            callView.Invoke(new Action(() =>
                            {
                                DoEvent(evt);
                            }));
                        }
                        catch (Exception ex)
                        {
                            log.Error(ex.Message);
                        }
                        PlcmProxy.FreeEvent(evt.EventHandle);
                    }
                }
            });

            thread.Start();
        }