Example #1
0
 public ThreadWorker(ThreadQueue <string> queue, int index)
 {
     this.queue = queue;
     this.index = index;
     Thrd       = new Thread(this.Run);
     Thrd.Start();
 }
Example #2
0
        public TestThreadQueue(int count)
        {
            ThreadQueue <string> queue   = new ThreadQueue <string>();
            List <ThreadWorker>  threads = new List <ThreadWorker>();

            for (int i = 1; i <= count; i++)
            {
                threads.Add(new ThreadWorker(queue, i));
            }

            while (Console.KeyAvailable == false)
            {
                foreach (ThreadWorker thread in threads)
                {
                    thread.Push();
                    Thread.Sleep(500);
                }
            }

            foreach (ThreadWorker thread in threads)
            {
                thread.Active = false;
            }
        }