Universe.Framework.Utilities.UniverseThreadPool.QueueEvent C# (CSharp) Méthode

QueueEvent() public méthode

public QueueEvent ( System.Action delegat, int Priority ) : void
delegat System.Action
Priority int
Résultat void
        public void QueueEvent (Action delegat, int Priority)
        {
            if (delegat == null)
                return;

            queue.Enqueue (delegat);

            lock (Threads) {
                if (nthreads == 0 || (nthreads - nSleepingthreads < queue.Count - 1 && nthreads < Threads.Length)) {
                    for (int i = 0; i < Threads.Length; i++) {
                        if (Threads [i] == null) {
                            Thread thread = new Thread (ThreadStart) {
                                Priority = m_info.priority,
                                Name =
                                                        (m_info.Name == "" ? "UniverseThreadPool" : m_info.Name) + "#" + i,
                                IsBackground = true
                            };
                            try {
                                thread.Start (new [] { i });
                                Threads [i] = thread;
                                Sleeping [i] = 0;
                                nthreads++;
                            } catch {
                            }
                            return;
                        }
                    }
                } else if (nSleepingthreads > 0) {
                    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;
                        }
                    }
                }
            }
        }