예제 #1
0
        public void QueueEvent2(QueueItem2 delegat, int Priority, object obj)
        {
            if (delegat == null)
            {
                return;
            }
            object[] o = new object[] { delegat, obj };
            lock (queue)
            {
                queue.Enqueue(o);
            }

            if (nthreads < queue.Count && nthreads < Threads.Length)
            {
                lock (Threads)
                {
                    for (int i = 0; i < Threads.Length; i++)
                    {
                        if (Threads[i] == null)
                        {
                            Thread thread = new Thread(ThreadStart);
                            thread.Priority     = m_info.priority;
                            thread.Name         = "AuroraThrPool#" + i.ToString();
                            thread.IsBackground = true;
                            try
                            {
                                thread.Start(new int[] { i });
                                Threads[i]  = thread;
                                Sleeping[i] = 0;
                                nthreads++;
                            }
                            catch { }
                            return;
                        }
                    }
                }
            }
            else if (nSleepingthreads > 0)
            {
                lock (Threads)
                {
                    for (int i = 0; i < Threads.Length; i++)
                    {
                        if (Sleeping[i] == 1 && Threads[i].ThreadState == ThreadState.WaitSleepJoin)
                        {
                            Threads[i].Interrupt(); // if we have a sleeping one awake it
                            return;
                        }
                    }
                }
            }
        }
예제 #2
0
        public void QueueEvent2(QueueItem2 delegat, int Priority, object obj)
        {
            if (delegat == null)
                return;
            object[] o = new object[]{delegat, obj };
            lock (queue)
            {
                queue.Enqueue(o);
            }

            if (nthreads < queue.Count && nthreads < Threads.Length)
                {
                lock (Threads)
                    {
                    for (int i = 0; i < Threads.Length; i++)
                        {
                        if (Threads[i] == null)
                            {
                            Thread thread = new Thread(ThreadStart);
                            thread.Priority = m_info.priority;
                            thread.Name = "Aurora Thread Pool Thread #" + 0;
                            thread.IsBackground = true;
                            Sleeping[i] = false;
                            Threads[i] = thread;
                            nthreads++;
                            thread.Start(new int[] { i });
                            return;
                            }

                        else if (Sleeping[i] && Threads[i].ThreadState == ThreadState.WaitSleepJoin)
                            Threads[i].Interrupt(); // if we have a sleeping one awake it
                        }
                    }
                }
        }
예제 #3
0
 public void QueueEvent2(QueueItem2 delegat, int Priority, object obj)
 {
     if (delegat == null)
         return;
     object[] o = new object[]{delegat, obj };
     lock (queue)
     {
         queue.Enqueue(o);
     }
     lock (Threads)
     {
         for (int i = 0; i < Threads.Length; i++)
         {
             if (Threads[i] != null)
                 return;
         }
         Thread thread = new Thread(ThreadStart);
         thread.Name = "Aurora Thread Pool Thread #" + 0;
         thread.Start(new int[] { 0, 0 }); //Set to 0 here to send the check for more threads the first time and 0 for the 0th thread
         Threads[0] = thread;
     }
 }