域对象“已更改”事件多次触发?

发布于 2025-01-05 08:13:02 字数 520 浏览 0 评论 0原文

我有一个自定义窗口来显示输入树中的各种对象。一旦在输入树上检查了对象并将其显示在窗口中,我就会订阅该对象的“Changed”事件。我绝对确定我没有多次订阅该活动。我看到的问题是当我更改对象(例如颜色)时,事件会触发 3 次。

伪代码:

- 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)

编辑:
我注意到,只要打开设置并单击“确定”而不更改任何内容,就会导致 3 个事件被触发。所以现在我认为它实际上与改变颜色无关。

我还尝试检查 DomainObjectChangeEventArgs PropertyNames 属性,但它始终为空。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

这个俗人 2025-01-12 08:13:02

看起来 Changed 事件正在被逐步淘汰,取而代之的是 ColorInfo.ColorChanged、ImageInfo.ImageChanged 等。事实上,从 2011 年开始,Changed 事件不再针对颜色更改而触发。事实证明,还有其他潜在因素导致了该事件的发生。

不管怎样,长话短说,不要使用 Changed 事件。

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.

装迷糊 2025-01-12 08:13:02

我无法确认这一行为,我只收到一个事件 - 您能告诉我们您正在使用哪个版本吗?并且 - 您是通过代码还是通过设置页面更改颜色?

就我而言,在这两种情况下我都收到了一次回调。

谢谢

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

指尖凝香 2025-01-12 08:13:02

我也收到一项活动。我正在使用 2011.1 和来自钻孔 ColorInfo 的 ColorChanged 事件。

在其他情况下,我确实看到多个事件,但这些事件发生在数据更改触发其他钻孔相关数据的更改时。例如,更改KB会导致大量的底层计算并导致多个事件触发。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文