int CountTrue(SRange range)
 {
     int total = 0;
     for (int i = range.lower; i <= range.upper; ++i)
         if (TestValue(i)) total++;
     return total;
 }
        private void frmMain_Load(object sender, EventArgs e)
        {
            int lower = 1000000000;
            int upper = 1100000000;
            int range = upper - lower;
            int inc = range / 4;
            int current = lower;
            Thread t = null;
            SRange s;

            tbOutput.Text = "Calculating...";

            for (int i = 0; i < 3; ++i)
            {
                s = new SRange(current, current + inc);
                current = current + inc + 1;
                t = new Thread(new ParameterizedThreadStart(ThreadWork));
                t.Start(s);
                t.IsBackground = true;
                threads.Add(t);
            }

            s = new SRange(current, upper);
            t = new Thread(new ParameterizedThreadStart(ThreadWork));
            t.Start(s);
            t.IsBackground = true;
            threads.Add(t);

            timer.Enabled = true;
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            int    lower   = 1000000000;
            int    upper   = 1100000000;
            int    range   = upper - lower;
            int    inc     = range / 4;
            int    current = lower;
            Thread t       = null;
            SRange s;

            tbOutput.Text = "Calculating...";

            for (int i = 0; i < 3; ++i)
            {
                s       = new SRange(current, current + inc);
                current = current + inc + 1;
                t       = new Thread(new ParameterizedThreadStart(ThreadWork));
                t.Start(s);
                t.IsBackground = true;
                threads.Add(t);
            }

            s = new SRange(current, upper);
            t = new Thread(new ParameterizedThreadStart(ThreadWork));
            t.Start(s);
            t.IsBackground = true;
            threads.Add(t);

            timer.Enabled = true;
        }
        int CountTrue(SRange range)
        {
            int total = 0;

            for (int i = range.lower; i <= range.upper; ++i)
            {
                if (TestValue(i))
                {
                    total++;
                }
            }
            return(total);
        }