Question

I have a custom window to display various objects from the input tree. Once an object is checked on the input tree and displayed in the window, I subscribe to the object's "Changed" event. I am absolutely sure that I did not subscribe to the event more than once. The problem I'm seeing is when I make changes to the object, such as color, the event fires 3 times.

pseudocode:

- Draw a borehole in a custom window<br />
- borehole.Changed += borehole_Changed<br />
- Change the color of the borehole<br />
- See event fire 3 times (I just added debug prints)

Edit:
I have noticed that just opening the settings and clicking "ok" without changing anything causes the 3 events to be fired. So now I assume it actually has nothing to do with changing the color.

I have also tried checking the DomainObjectChangeEventArgs PropertyNames property, but that is always empty.

Was it helpful?

Solution

It looks like the Changed event is being phased out in favor of ColorInfo.ColorChanged, ImageInfo.ImageChanged, etc. In fact, the Changed event is not fired anymore as of 2011 for color changes. Turns out that there were other things underlying that caused the event to fire.

Anyways, to make a long story short, don't use the Changed event.

OTHER TIPS

I can't confirm this behavior, I only get one event - can you please tell us which version you are using? And - are you changing the color via code or via the settings page?

In my case I got a single callback in both cases.

Thanks

I am getting one event also. I am using 2011.1 and the ColorChanged event from the ColorInfo for the Borehole.

In other cases I do see multiple events, but these happen when the data changed triggers changes to other Borehole related data. For example, changing the KB will cause lots of underlying calculations and result in multiple event triggers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top