Example #1
0
            public Thread NewThread(IRunnable r)
            {
                var t = new Thread(r.Run, 0)
                {
                    Name = _namePrefix + _threadNumber.ReturnValueAndIncrement()
                };

                // Lower the priority of the peer threads. This is to avoid competing with UI threads created by the API
                // user when doing lots of work, like downloading the block chain. We select a priority level one lower
                // than the parent thread, or the minimum.
                t.Priority     = (ThreadPriority)Math.Max((int)ThreadPriority.Lowest, ((int)Thread.CurrentThread.Priority) - 1);
                t.IsBackground = true;
                return(t);
            }
Example #2
0
            public virtual Thread NewThread(IRunnable r)
            {
                var t = new Thread(r.Run);

                t.Name = namePrefix + threadNumber.ReturnValueAndIncrement();
                if (t.IsBackground)
                {
                    t.IsBackground = false;
                }
                if (t.Priority != ThreadPriority.Normal)
                {
                    t.Priority = ThreadPriority.Normal;
                }
                return(t);
            }
Example #3
0
            public virtual Thread NewThread(IRunnable r)
            {
                var t = new Thread(r.Run)
                {
                    Name = NamePrefix + ThreadNumber.ReturnValueAndIncrement()
                };

                if (t.IsBackground)
                {
                    t.IsBackground = false;
                }
                // ReSharper disable RedundantCheckBeforeAssignment
                if (t.Priority != ThreadPriority.Normal)
                {
                    // ReSharper restore RedundantCheckBeforeAssignment
                    t.Priority = ThreadPriority.Normal;
                }
                return(t);
            }
Example #4
0
 internal DefaultThreadFactory()
 {
     namePrefix = "pool-" + poolNumber.ReturnValueAndIncrement() + "-thread-";
 }
Example #5
0
 public PeerGroupThreadFactory()
 {
     _namePrefix = "PeerGroup-" +
                   _poolNumber.ReturnValueAndIncrement() +
                   "-thread-";
 }