Example #1
0
 public void ThreadPoolTest()
 {
     for (int i = 0; i < 10000; i++)
     {
         var o1 = ThreadFoo.Create(i);
         var o2 = new ThreadFoo(o1);
         ThreadPool.QueueUserWorkItem(state =>
         {
             var arr = state as ThreadFoo[];
             CreateComparator().Compare(arr[0], arr[1]);
         }, new ThreadFoo[] { o1, o2 });
     }
 }
        public void ThreadPoolTest()
        {
            var events = new List <ManualResetEvent>();

            for (int i = 0; i < 64; i++)
            {
                var resetEvent = new ManualResetEvent(false);
                var o1         = ThreadFoo.Create(i);
                var o2         = new ThreadFoo(o1);
                ThreadPool.QueueUserWorkItem(state =>
                {
                    var arr = state as ThreadFoo[];
                    CreateComparator().Compare(arr[0], arr[1]);
                    resetEvent.Set();
                }, new ThreadFoo[] { o1, o2 });
                events.Add(resetEvent);
            }

            WaitHandle.WaitAll(events.ToArray());
        }
 public ThreadFoo(ThreadFoo other)
 {
     Line1 = other.Line1;
     Line2 = other.Line2;
     Line3 = other.Line3;
 }
 public ThreadFoo(ThreadFoo other)
 {
     Line1 = other.Line1;
     Line2 = other.Line2;
     Line3 = other.Line3;
 }