コード例 #1
0
        private void backgroundWorker_DoWork(object s, DoWorkEventArgs args)
        {
            Object[] arguments = (Object[])args.Argument;
            int      n         = (int)arguments[0];
            int      dim       = (int)arguments[1];
            double   d         = (double)arguments[2];
            Point    X         = (Point)arguments[3];

            ObservableCollection <PointWrapper> sample = new ObservableCollection <PointWrapper>();
            int       totalPoints = 0;
            int       validPoint  = 0;
            Stopwatch stopwatch   = Stopwatch.StartNew();

            //MAIN PROCEDURE LOOP!!
            while (sample.Count < n)
            {
                if (bgWorker.CancellationPending)
                {
                    args.Cancel = true;
                    return;
                }

                Point point = null;

                Console.WriteLine("\nPOINT No " + (totalPoints + 1) + " \n");
                point = planeProjector.makePoint(X, d, dim);

                point = pointProcessor.processPoint(point, X);

                PointWrapper pointData = new PointWrapper(point, X, d);
                if (pointData.IsValid)
                {
                    sample.Add(pointData);
                    validPoint++;
                }
                totalPoints++;

                double time = stopwatch.ElapsedMilliseconds;
                UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateProgressText);
                progressWindow.Dispatcher.BeginInvoke(update, (validPoint * 100) / n, totalPoints, time);
            }
            stopwatch.Stop();

            args.Result = sample;
        }
コード例 #2
0
        private void backgroundWorker_DoWork(object s, DoWorkEventArgs args)
        {
            Object[] arguments = (Object[])args.Argument;
            int n = (int)arguments[0];
            int dim = (int)arguments[1];
            double d = (double)arguments[2];
            Point X = (Point)arguments[3];

            ObservableCollection<PointWrapper> sample = new ObservableCollection<PointWrapper>();
            int totalPoints = 0;
            int validPoint = 0;
            Stopwatch stopwatch = Stopwatch.StartNew();
            //MAIN PROCEDURE LOOP!!
            while (sample.Count < n)
            {

                if (bgWorker.CancellationPending)
                {
                    args.Cancel = true;
                    return;
                }

                Point point = null;

                Console.WriteLine("\nPOINT No " + (totalPoints + 1) + " \n");
                point = planeProjector.makePoint(X, d, dim);

                point = pointProcessor.processPoint(point, X);

                PointWrapper pointData = new PointWrapper(point, X, d);
                if (pointData.IsValid)
                {
                    sample.Add(pointData);
                    validPoint++;
                }
                totalPoints++;

                double time = stopwatch.ElapsedMilliseconds;
                UpdateProgressDelegate update = new UpdateProgressDelegate(UpdateProgressText);
                progressWindow.Dispatcher.BeginInvoke(update, (validPoint * 100) / n, totalPoints, time);
            }
            stopwatch.Stop();

            args.Result = sample;
        }