/* * 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); } } }
void m_FunctionPix_Executed(object obj) { if (PrimesCountList.Initialzed && m_To.LongValue <= PrimesCountList.MaxNumber) { ControlHandler.SetPropertyValue(lblCalcInfoPiX, "Text", Primes.Resources.lang.WpfControls.Distribution.Distribution.graph_pincountinfo); SetInfo(tbInfoPiX, PrimesCountList.GetPrime(m_To.LongValue)); } else { SetInfo(tbInfoPiX, obj); } }
private void CalculatePiX() { 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(); } }
public double Execute(double input) { long value = (long)input; if (usePrimesCountList) { usePrimesCountList = PrimesCountList.Initialzed; } if (PrimesCountList.Initialzed && usePrimesCountList) { if (value <= PrimesCountList.MaxNumber) { m_FormerValue = m_Counter; m_Counter = PrimesCountList.GetPrime((long)input); m_LastNumber = value; } else { m_Counter = PrimesCountList.GetPrime(PrimesCountList.MaxNumber); m_LastNumber = PrimesCountList.MaxNumber; usePrimesCountList = false; } } else { long i = value / 100000; if (i < PrimeNumbers.numberofprimes.Length) { m_Counter = PrimeNumbers.numberofprimes[i]; m_LastNumber = i * 100000; } } if (PrimesBigInteger.ValueOf(m_LastNumber).IsPrime(10)) { m_LastNumber++; } while (m_LastNumber < value) { if (PrimesBigInteger.ValueOf(m_LastNumber).IsPrime(10)) { m_Counter++; if (m_ShowIntermediateResult && Executed != null) { Executed(m_Counter); } } m_LastNumber++; } if (PrimesBigInteger.ValueOf(value).IsPrime(10) && !usePrimesCountList) { m_FormerValue = m_Counter; m_Counter++; } m_LastNumber = value; if (Executed != null) { Executed(m_Counter); } return(m_Counter); }