Example #1
0
        /*
         * long n = 2;
         * long counter = 0;
         * if (PrimesCountList.Initialzed)
         * {
         *  n = PrimesCountList.MaxNumber;
         *  counter = PrimesCountList.GetPrime(n);
         * }
         * m_FunctionPix_Executed(n);
         * m_FunctionPix.FunctionState = FunctionState.Running;
         *
         * while (n < m_To.LongValue)
         * {
         *  n++;
         *  counter = (long)m_FunctionPix.Execute(n);
         * }
         * m_FunctionPix.FunctionState = FunctionState.Stopped;
         * if (OnStopPiX != null) OnStopPiX();
         */

        protected override void OnDoWork()
        {
            if (OnFunctionStart != null)
            {
                OnFunctionStart(m_FunctionPiX);
            }
            if (m_FunctionPiX != null)
            {
                if (PrimesCountList.Initialzed)
                {
                    n       = PrimesCountList.MaxNumber;
                    counter = PrimesCountList.GetPrime(n);
                }
                m_objdelegate(n);
                m_FunctionPiX.FunctionState = FunctionState.Running;
                while (!HasTerminateRequest() && n < m_To.LongValue)
                //for (long i = m_From; i <= fe.Range.To * factor || !HasTerminateRequest(); i += inci)
                {
                    Boolean awokenByTerminate = SuspendIfNeeded();

                    if (awokenByTerminate)
                    {
                        return;
                    }
                    n++;
                    counter = (long)m_FunctionPiX.Execute(n);
                }
                m_FunctionPiX.Reset();
                m_FunctionPiX.FunctionState = FunctionState.Stopped;
                if (OnFunctionStop != null)
                {
                    OnFunctionStop(m_FunctionPiX);
                }
            }
        }
Example #2
0
 public void DoCountPrimes(object o)
 {
     if (o != null && o.GetType() == typeof(PrimesBigInteger))
     {
         FunctionPiX func = new FunctionPiX();
         func.ShowIntermediateResult = true;
         m_refreshcount = 0;
         func.Executed += new ObjectParameterDelegate(func_Executed);
         double erg = func.Execute((o as PrimesBigInteger).DoubleValue);
         ControlHandler.SetPropertyValue(lblInfoCountPrimes, "Text", StringFormat.FormatDoubleToIntString(erg));
     }
 }
Example #3
0
        protected override void DoExecute()
        {
            FireOnStart();

            FunctionPiX      pix         = new FunctionPiX();
            PrimesBigInteger from        = m_From;
            PrimesBigInteger _counterTmp = PrimesBigInteger.Two;

            while (_counterTmp.CompareTo(from) <= 0)
            {
                double result = pix.Execute(_counterTmp.DoubleValue);
                FireOnMessage(this, from, StringFormat.FormatDoubleToIntString(result));
                _counterTmp = _counterTmp.Add(PrimesBigInteger.One);
            }

            while (from.CompareTo(m_To) <= 0)
            {
                double result = pix.Execute(from.DoubleValue);
                FireOnMessage(this, from, StringFormat.FormatDoubleToIntString(result));
                from = from.Add(PrimesBigInteger.One);
            }

            FireOnStop();
        }