System.Threading.ThreadPool.QueueUserWorkItem C# (CSharp) Méthode

QueueUserWorkItem() public static méthode

public static QueueUserWorkItem ( System callBack ) : bool
callBack System
Résultat bool
        public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack)
        {
            throw null;
        }

Same methods

ThreadPool::QueueUserWorkItem ( System callBack, object state ) : bool

Usage Example

        /// <summary>
        /// setup for threads
        /// </summary>
        public void GenerateThreads()
        {
            try
            {
                int i = 1;
                foreach (Reactor reactor in this.reactors)
                {
                    switch (reactor.selectedThreadingType)
                    {
                    case ThreadingType.SingleThreading:
                        reactor.ExecuteThread();
                        break;

                    case ThreadingType.MultiThreading:
                        Thread thread = new Thread(reactor.ExecuteThread)
                        {
                            Name = reactor.ToString() + i
                        };
                        thread.Start();
                        break;

                    case ThreadingType.ThreadPool:
                        ThreadPool.QueueUserWorkItem(reactor.ThreadProcess);
                        break;
                    }
                    Thread.Sleep(100);
                    i++;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("\n\n\n\nException\nmessage: {0}\nStacktrace: {1}", e.Message, e.StackTrace);
            }
        }