예제 #1
0
        public static async Task MainLoop()
        {
            run = true;
            while (run)
            {
                try
                {
                    lock (warnings)
                    {
                        foreach (var item in warnings)
                        {
                            // check primary condition
                            if (checkCond(item))
                            {
                                //Check item type
                                if (item.type == CustomWarning.WarningType.SpeakAndText)
                                {
                                    if (_speech != null)
                                    {
                                        while (!_speech.IsReady)
                                        {
                                            Thread.Yield();
                                        }

                                        _speech.SpeakAsync(item.SayText());
                                    }

                                    WarningMessage?.Invoke(null, item.SayText());
                                }
                                else if (item.type == CustomWarning.WarningType.Coloring)
                                {
                                    QuickPanelColoring?.Invoke(item.Name, item.color);
                                }
                            }
                            // if condition is not met, then color back the QV panel to default BackGround
                            else if (item.type == CustomWarning.WarningType.Coloring)
                            {
                                QuickPanelColoring?.Invoke(item.Name, "NoColor");
                            }
                        }
                    }
                }
                catch
                {
                }

                await Task.Delay(250).ConfigureAwait(false);
            }
        }
예제 #2
0
        public static void MainLoop()
        {
            run = true;
            while (run)
            {
                try
                {
                    lock (warnings)
                    {
                        foreach (var item in warnings)
                        {
                            // check primary condition
                            if (checkCond(item))
                            {
                                if (_speech != null)
                                {
                                    while (!_speech.IsReady)
                                    {
                                        System.Threading.Thread.Sleep(10);
                                    }

                                    _speech.SpeakAsync(item.SayText());
                                }

                                WarningMessage?.Invoke(null, item.SayText());
                            }
                        }
                    }
                }
                catch
                {
                }

                System.Threading.Thread.Sleep(100);
            }
        }