Пример #1
0
        public void RunOnThread(BrowserHost host, PipeServer server)
        {
            SetForcedFps(true, 16);

            try
            {
                Logr.Log("Started task runner.");

                while (KeepAlive)
                {
                    lock (_taskList)
                    {
                        while (_taskList.Count > 0)
                        {
                            var nextTask = _taskList.Dequeue();

                            try
                            {
                                if (_enableForcedFps && (nextTask is SendFrameTask || nextTask is RepaintFrameTask))
                                {
                                    _idleTicks = 0;
                                }

                                nextTask.Run(host, server);
                            }
                            catch (Exception ex)
                            {
                                Logr.Log("Exception while executing internal task:", ex.Message, ex);
                            }
                        }

                        if (_enableForcedFps && _idleTicks++ >= _autoRepaintTicks)
                        {
                            host.Repaint();
                        }
                    }

                    Thread.Sleep(1); // we need to run more than 30 times per second for frame transfers
                }

                Logr.Log("Task runner shutting down.");
            }
            catch (ThreadInterruptedException) { }
            catch (ThreadAbortException) { }
        }