Beispiel #1
0
            protected virtual void OnComplete()
            {
                AnalysisMember analysisMember = this as AnalysisMember;

                if (analysisMember == null || analysisMember is RootAnalysisMember)
                {
                    return;
                }
                try
                {
                    this.analysis.OnAnalysisMemberStop(analysisMember);
                }
                catch (Exception inner)
                {
                    this.analysis.Cancel(new CriticalException(analysisMember, inner));
                }
                bool isAnalysisComplete = false;

                if (analysisMember.IsConclusion)
                {
                    AnalysisProgress unsafeValue     = this.analysis.currentProgress.UnsafeValue;
                    AnalysisProgress updatedProgress = new AnalysisProgress(unsafeValue.TotalConclusions, unsafeValue.CompletedConclusions + 1);
                    isAnalysisComplete = (updatedProgress.CompletedConclusions == updatedProgress.TotalConclusions);
                    this.analysis.currentProgress.Update(unsafeValue, updatedProgress, delegate(AnalysisProgress original, AnalysisProgress current, AnalysisProgress updated)
                    {
                        isAnalysisComplete = (updatedProgress.CompletedConclusions == updatedProgress.TotalConclusions);
                        return(new AnalysisProgress(current.TotalConclusions, current.CompletedConclusions + 1));
                    });
                    EventHandler <ProgressUpdateEventArgs> progressUpdated = this.analysis.ProgressUpdated;
                    if (progressUpdated != null)
                    {
                        try
                        {
                            progressUpdated(this.analysis, new ProgressUpdateEventArgs(updatedProgress));
                        }
                        catch (Exception inner2)
                        {
                            this.analysis.Cancel(new CriticalException(analysisMember, inner2));
                        }
                    }
                }
                if (isAnalysisComplete)
                {
                    this.analysis.CompleteAnalysis();
                }
            }
Beispiel #2
0
        private void CompleteAnalysis()
        {
            Analysis.AnalysisState safeValue  = this.currentState.SafeValue;
            AnalysisProgress       safeValue2 = this.currentProgress.SafeValue;

            if (!safeValue.IsStarted || safeValue2.CompletedConclusions != safeValue2.TotalConclusions)
            {
                return;
            }
            Analysis.AnalysisState updatedValue = safeValue.SetAsCompleted();
            this.currentState.Update(safeValue, updatedValue);
            try
            {
                this.OnAnalysisStop();
            }
            catch (Exception inner)
            {
                this.Cancel(new CriticalException(null, inner));
            }
            this.completedManualResetEvent.Set();
        }
Beispiel #3
0
 internal static AnalysisProgress Resolve(AnalysisProgress originalValue, AnalysisProgress currentValue, AnalysisProgress updatedValue)
 {
     return(new AnalysisProgress(Math.Max(updatedValue.TotalConclusions, currentValue.TotalConclusions), Math.Max(updatedValue.CompletedConclusions, currentValue.CompletedConclusions)));
 }
 public ProgressUpdateEventArgs(AnalysisProgress progress)
 {
     this.progress = progress;
 }
Beispiel #5
0
        public void StartAnalysis()
        {
            Analysis.AnalysisState unsafeValue = this.currentState.UnsafeValue;
            if (unsafeValue.IsStarted || unsafeValue.IsCanceled)
            {
                return;
            }
            lock (this.startAnalysisLock)
            {
                Analysis.AnalysisState safeValue = this.currentState.SafeValue;
                if (safeValue.IsStarted || unsafeValue.IsCanceled)
                {
                    return;
                }
                Analysis.AnalysisState updatedValue = safeValue.SetAsStarted();
                this.currentState.Update(safeValue, updatedValue);
            }
            AnalysisProgress progress = this.currentProgress.Update(this.currentProgress.UnsafeValue, new AnalysisProgress((from x in this.AnalysisMembers
                                                                                                                            where !(x is RootAnalysisMember)
                                                                                                                            select x).Count((AnalysisMember x) => x.IsConclusion), 0));

            try
            {
                this.OnAnalysisStart();
            }
            catch (Exception inner)
            {
                this.Cancel(new CriticalException(null, inner));
            }
            EventHandler <ProgressUpdateEventArgs> progressUpdated = this.ProgressUpdated;

            if (progressUpdated != null)
            {
                progressUpdated(this, new ProgressUpdateEventArgs(progress));
            }
            List <AnalysisMember> source = (from x in this.AnalysisMembers
                                            where x.IsConclusion
                                            select x).ToList <AnalysisMember>();

            if (source.Any <AnalysisMember>())
            {
                if (this.threadMode == AnalysisThreading.Single)
                {
                    using (IEnumerator <AnalysisMember> enumerator = (from x in source
                                                                      orderby(int) x.EvaluationMode
                                                                      select x).GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AnalysisMember analysisMember = enumerator.Current;
                            analysisMember.Start();
                        }
                        return;
                    }
                }
                using (IEnumerator <AnalysisMember> enumerator2 = (from x in this.AnalysisMembers
                                                                   where x.EvaluationMode == Evaluate.OnAnalysisStart && this.immediateEvaluationFilter(x)
                                                                   select x).GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        AnalysisMember member = enumerator2.Current;
                        Task.Factory.StartNew(delegate()
                        {
                            member.Start();
                        }, TaskCreationOptions.LongRunning);
                    }
                }
                Parallel.ForEach <AnalysisMember>((from x in this.AnalysisMembers
                                                   where x.IsConclusion && (x.EvaluationMode != Evaluate.OnAnalysisStart || !this.immediateEvaluationFilter(x))
                                                   select x).ToList <AnalysisMember>(), delegate(AnalysisMember x)
                {
                    x.Start();
                });
                return;
            }
            this.CompleteAnalysis();
        }