Beispiel #1
0
        private void Go(Control GDI, int threadCount)
        {
            ProgressBar1.Maximum = scrWidth * scrHeight;
            ProgressBar1.Value   = 0;
            progress             = 0;
            workerThreads        = new Thread[threadCount];
            MandelBrotSet[] workers  = new MandelBrotSet[threadCount];
            int             workLoad = scrHeight / threadCount;

            for (int i = 0; i < threadCount; i++)
            {
                workers[i]            = new MandelBrotSet(this, scrWidth, scrHeight, translX, translY, (double)zoom, i * workLoad, (i + 1) * workLoad);
                workerThreads[i]      = new Thread(workers[i].Start);
                workerThreads[i].Name = "worker " + i;
            }


            stopwatch.Reset();
            stopwatch.Start();
            //Stopwatch stopwatch1 = new Stopwatch();
            //stopwatch1.Start();
            foreach (Thread item in workerThreads)
            {
                item.Start();
            }

            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 50;
            timer.Tick    += OnTick;
            timer.Start();

            //foreach (var workerThread in workerThreads)
            //{
            //    workerThread.Join();
            //}
            //stopwatch1.Stop();
            //MessageBox.Show("Thread time was = " + stopwatch1.ElapsedTicks);
        }
Beispiel #2
0
        private void Go(Control GDI, int threadCount)
        {
            ProgressBar1.Maximum = scrWidth * scrHeight;
            ProgressBar1.Value = 0;
            progress = 0;
            workerThreads = new Thread[threadCount];
            MandelBrotSet[] workers = new MandelBrotSet[threadCount];
            int workLoad = scrHeight / threadCount;
            for (int i = 0; i < threadCount; i++)
            {
                workers[i] = new MandelBrotSet(this, scrWidth, scrHeight, translX, translY, (double)zoom, i * workLoad, (i + 1) * workLoad);
                workerThreads[i] = new Thread(workers[i].Start);
                workerThreads[i].Name = "worker " + i;
            }

            stopwatch.Reset();
            stopwatch.Start();
            //Stopwatch stopwatch1 = new Stopwatch();
            //stopwatch1.Start();
            foreach (Thread item in workerThreads)
            {
                item.Start();
            }

            timer = new System.Windows.Forms.Timer();
            timer.Interval = 50;
            timer.Tick += OnTick;
            timer.Start();

            //foreach (var workerThread in workerThreads)
            //{
            //    workerThread.Join();
            //}
            //stopwatch1.Stop();
            //MessageBox.Show("Thread time was = " + stopwatch1.ElapsedTicks);
        }