views:

38

answers:

1

I am trying to change the active index of a multiview by using a delegate and it doesn't work as i expect.

this is my code

        protected void ucWaitPage_FinishedWaiting(PerformAfterWaitDelegate performAfterWait)
    {
        performAfterWait.Invoke();
        this.SetIndex();
    }

    private void SetIndex()
    {
        this.mvwTest.ActiveViewIndex = 0;
    }

The performAfterWait Delegate points to the SetIndex() method.

When the performAfterWait delegate gets invoked SetIndex() gets called but when SetIndex() returns this.mvwTest.ActiveViewIndex reverts to being equal to 1.

However when i call the SetIndex() method directly it sets this.mvwTest.ActiveViewIndex = 0 and the change persists when the method returns.

A: 

When the performAfterWait delegate gets invoked SetIndex() gets called but when SetIndex() returns this.mvwTest.ActiveViewIndex reverts to being equal to 1.

How do you verify this, can you put Debug.WriteLine(this.mvwTest.ActiveViewIndex) after the invoke function?

By the way, what do you want to use invoke to call that method? Do you just want to test the delegate. I don't see the advantage if you are still calling from the same thread.

J.W.