Esempio n. 1
0
        void ThreadLoop()
        {
            var keepRunning = true;

            while (keepRunning)
            {
                System.Threading.Thread.Sleep(10);
                switch (m_Thread.ThreadState)
                {
                case System.Threading.ThreadState.Aborted:
                case System.Threading.ThreadState.AbortRequested:
                case System.Threading.ThreadState.Stopped:
                case System.Threading.ThreadState.StopRequested:
                    keepRunning = false;
                    break;
                }

                AbstractThreadJob job = null;

                lock (m_ThreadJobs)
                {
                    if (m_ThreadJobs.Count == 0)
                    {
                        continue;
                    }

                    job = m_ThreadJobs[0];
                    m_ThreadJobs.RemoveAt(0);
                }

                job.state = AbstractThreadJob.State.Running;
                try
                {
                    m_Repaint = true;
                    job.ThreadFunc();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    throw e;
                }
                catch (System.Exception e)
                {
                    m_Exceptions.Add(e);
                }
                finally
                {
                    m_Repaint = true;
                    job.state = AbstractThreadJob.State.Completed;
                }

                lock (m_IntegrationJobs)
                {
                    m_IntegrationJobs.Add(job);
                }
            }
        }
        void ThreadLoop()
        {
            while (!isClosing)
            {
                AbstractThreadJob job = null;

                lock (m_ThreadJobs)
                {
                    while (m_ThreadJobs.Count == 0)
                    {
                        Monitor.Wait(m_ThreadJobs); // block myself, waiting for jobs
                        if (isClosing)
                        {
                            return; // exit
                        }
                    }

                    job = m_ThreadJobs[0];
                    m_ThreadJobs.RemoveAt(0);
                }

                job.state = AbstractThreadJob.State.Running;
                try
                {
                    m_Repaint = true;
                    job.ThreadFunc();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    throw e;
                }
                catch (System.Exception e)
                {
                    m_Exceptions.Add(e);
                }
                finally
                {
                    m_Repaint = true;
                    job.state = AbstractThreadJob.State.Completed;
                }

                lock (m_IntegrationJobs)
                {
                    m_IntegrationJobs.Add(job);
                }
            }
        }
Esempio n. 3
0
        public void ScheduleJob(AbstractThreadJob job)
        {
            job.state = AbstractThreadJob.State.Queued;

            lock (m_ThreadJobs)
            {
                // Remove unstarted jobs of same type
                for (var n = m_ThreadJobs.Count - 1; n >= 0; --n)
                {
                    var j = m_ThreadJobs[n];
                    if (j.state == AbstractThreadJob.State.Queued && j.GetType() == job.GetType())
                    {
                        m_ThreadJobs.RemoveAt(n);
                        continue;
                    }
                }

                m_ThreadJobs.Add(job);
            }

            m_Repaint = true;
        }
Esempio n. 4
0
 protected void ScheduleJob(AbstractThreadJob job)
 {
     window.ScheduleJob(job);
 }