tomfumb

ITrackCancel not correctly reporting Continue()

Discussion created by tomfumb on Jun 29, 2011
I'm developing a custom ArcObjects ArcMap Add-in (v10 SP1) and have a very irritating issue with cancelling my task part-way through. I believe the issue is related to something being passed by value instead of reference but I can't figure it.

I've posted the relevant parts of my code below with a bit of explanation. Any assistance on this would be very much appreciated as I'm totally stumped!

- private variables in tool's main class
private IProgressDialog2 m_currentDialog = null;
private ITrackCancel m_trackCancel;


- public function providing access to the dialog
public void updateProgressDialog(string message)
        {
            if (this.m_currentDialog == null)
            {
                this.m_trackCancel = new CancelTrackerClass();

                IProgressDialogFactory progressDialogFactory = new ProgressDialogFactoryClass();
                this.m_currentDialog = (IProgressDialog2)progressDialogFactory.Create(this.m_trackCancel, 0);

                this.m_currentDialog.CancelEnabled = true;
                this.m_currentDialog.Title = ThisAddIn.Name;
                this.m_currentDialog.Animation = esriProgressAnimationTypes.esriProgressSpiral;

                IStepProgressor stepProgressor = (IStepProgressor)this.m_currentDialog;
                stepProgressor.Hide();

                this.m_currentDialog.ShowDialog();
            }

            this.m_currentDialog.Description = message;
        }


- main class providing access to cancelled state of cancel tracker
public bool isCancelled()
        {
            return !this.m_trackCancel.Continue();
        }


- separate class's function (the tool's main object is passed by reference to provide access to its dialog update function) contains the following statement
if (caller.isCancelled())
                        {
                            editWorkspace.AbortEditOperation();

                            return;
                        }


No matter how many times I click the cancel button the main class's isCancelled function always returns false.

Outcomes