Skip to content

CP-65209: Bug in AlgorithmBase ?! #157

Description

@fubar-coder

From unknown CodePlex user on Friday, 02 September 2016 06:35:12

For my Version, I fixed the below in AlgorithmBase.cs (commented out the original code and added PendingAbortion state) and it works fine now when aborting an Algorithm using Abort().

The switch case for PendingAbortion will never be executed if the contract requires Aborted state.

        protected void EndComputation()
        {
            Contract.Requires(
                this.State == ComputationState.Running ||
                this.State == ComputationState.PendingAbortion
                /*this.State == ComputationState.Aborted*/);
            lock (this.syncRoot)
            {
                switch (this.state)
                {
                    case ComputationState.Running:
                        this.state = ComputationState.Finished;
                        this.OnFinished(EventArgs.Empty);
                        break;
                    case ComputationState.PendingAbortion:
                        this.state = ComputationState.Aborted;
                        this.OnAborted(EventArgs.Empty);
                        break;
                    default:
                        throw new InvalidOperationException();
                }
                this.Services.CancelManager.ResetCancel();
                this.OnStateChanged(EventArgs.Empty);
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions